I use telerik on c# wpf.
I have a GridViewCheckBoxColumn column in my table. I need the title of this column to contain CheckBox(which by default are to highlight the entire column) and name. Аnd so that the checkbox in the header marked all the elements of the table. How can I do it?
This is the expected outcome:
https://i.stack.imgur.com/Qwm1k.png
I think you have to use GridViewSelectColumn.
*`<telerik:GridViewSelectColum/>`*
Add to 'Header' property to this xaml code.
Good luck
I'm Chuffed I can help you, ZakharovV
<telerik:RadGridView.Columns>
<telerik:GridViewSelectColumn>
<telerik:GridViewSelectColumn.Header>
<CheckBox>My Header</CheckBox>
</telerik:GridViewSelectColumn.Header>
</telerik:GridViewSelectColumn>
</telerik:RadGridView.Columns>
"GridViewSelectColumn.Header" is important
Good Luck
Related
I use Visual-Studio-2012. Basically I have 5 column DataGridView with product,quantity,price,+,- and I would like to align all text of products I put into my basket as MiddleCentered except actual Product description (it stays MiddleLeft as default).
I can change aligment via RowHeadersDefaultCellStyle, but I can't choose which columns I would like to align and it makes all of them MiddleCentered.
Is there any way to do so? I was trying to search on the NET, but didn't find anything clear. Help would be very appreciated.
As you have not posted your code, here is a way to aligning the text,
dataGridView1.Columns["ColumnName"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
Give a try and if you still not able to align the text, please post your code.
Holly spirit, I found the answer. I can change it via Edit Columns, selecting column and changing aligment. How stupid do I feel now. Damn...Sorry to bother guys.
I'm sure the answer to this question is incredibly obvious, but for the life of me I can't figure out how to remove the "selector" column from the default winforms gridview. (The column the red arrow is pointing at).
I've tried programmatically removing the column gridview.Columns[0].Remove but that just removed my first data column. It doesn't show up in the "column collection" also, and I've played with all the settings that looked somewhat promising.
Thanks for the help!
Set the RowHeadersVisible to False in the GridView (it's a property)
I have a DevExpress WPF grid (version 9.3). When I export to excel, it has horrible additional rows* that completely mess up excel's functionality such as auto filter.
I've been trying to make sense of the documentation and I think that the solution may lie in setting TableView.PrintCellStyle somehow. But it's really not clear.
I am using the TableView.ExportToXls(string path); method.
Is there a quick way of switching off this behaviour and getting a working xls file?
*I understand that this is to help with creating a spreadsheet that looks the same as the grid. Horrible default behaviour - a working spreadsheet is more important than it looking like the UI.
EDIT: #DmitryG - I have tried this and now, instead of three lines I now get two. Better, but not solved.
I have also checked the KB article you cited and get the following result:
I am using version 9.3.6.
Anything else I can try?
EDIT 2: Have tried the value converter approach. Getting the same additional row.
Worst case, is there anyway of excluding these columns from the export?
As far as I can see the problem like yours was already discussed here:
Exporting Boolean Values causes Three Merged Rows To Appear for each Row of data.
The problem solution for version 9.3 was the direct assigning of the GridColumn.EditSettings property:
<dxg:GridColumn x:Name="Boolean" FieldName="Boolean">
<dxg:GridColumn.EditSettings>
<dxe:CheckEditSettings HorizontalContentAlignment="Center"/>
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
Please also review the following KB article:
How to change representation of data cells via PrintCellStyle when printing/exporting grid data.
P.S. This problem is absent in the latest versions.
DevExpress has significantly improved the export engine in the latest version 14.2 and now the issue should be solved.
Please refer to the following help article for more information:
Printing and Exporting
I was still getting the additional rows. The quickest and easiest way to get around this was to set the EditSettings of the column so it exports 'True' or 'False', export the grid then set the column back to a checkbox.
Thusly:
public void ExportGridToExcel()
{
TableView.Grid.Columns["*FieldName*"].EditSettings = new TextEditSettings();
TableView.ExportToXls(#"C:\temp\spreadsheet.xls");
TableView.Grid.Columns["*FieldName*"].EditSettings = new CheckEditSettings();
}
NB It's the fieldname the column is bound to and NOT the column name. That caught me out for a minute.
I am trying to set the width of a column in a Gridview in C# and it is not working at all. I have tried to set the header style and item style via the following method:
GridView1.Columns[0].ItemStyle.Width = Unit.Pixel(200);
and similarly for the header style. None of this seems to be working. I see many forums online that people are having a similar issue but after looking for approx 1h30m I still could not find one that also had a solution.
There is also one stipulation - all of the columns in my grid are dynamic so it must be something that I can set programatically - not in markup.
I appreciate any help on this issue!
EDIT: with the help of Jon and through some other research I believe the issue is because I have defined no columns in the markup. However, I have not figured out how to resolve this. I cannot place columns in the markup because the table is generated using repeaters on the back end. If anyone has any insight into this please let me know.
I had the same problem. I realized that because I was databinding my grid to a datasource, and because my gridview had the property of autosizing the columns, there is no way to set the width of the column afterwards. If you change that property to false, you should be able to programatically resize them.
EDIT: this is the markup you need somewhere inside your GridView markup:
<Columns>
<asp:BoundField DataField="your_database_column" />
<asp:BoundField DataField="your_next_database_column" />
...
</Columns>
Just setting GridView1.Columns[0].ItemStyle.Width = Unit.Pixel(100); ought to do it. The corresponding td should contain style="width:100px" when you do so. The header element's width need not be modified, as it's done so automatically.
Also set AutoGenerateColumns="false" in your Gridview declaration.
I would like to convert my dataset which contains one table into a datagrid in order to get the width of each column to add many groups title with the correct width just above.
I've tried " mydatagrid.ItemsSource = mydataset.Table[0].defaultview;" and it works properly
except this instruction doesn't fill any columns in my datagrid so i can't get any width of any columns.
If anyone have an idea, thanks a lot.
Have you set AutoGenerateColumns = true?
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datagrid.autogeneratecolumns.aspx
Your question sounds a bit strange. You DO know, that DataGrid is a web control, yes?
First of all, there are two DataGrid controls: one in System.Windows.Forms namespace for Windows Forms and the other in System.Web.UI.WebControls for Web.
In either case, DataGrid is a control that shows a data from a data source in a grid. In order to show the data, you have to bind it to a control.
This is quote from DataGrid article:
"To display a table in the System.Windows.Forms.DataGrid at run time, use the SetDataBinding method to set the DataSource and DataMember properties to a valid data source."
dataGrid1.SetDataBinding(SuppliersProducts, "Suppliers");
So i'm back with a solution.
My columns were empty cause my code was define before the event "Loaded" happen so now everything is perfect.
Thanks for precision about the datagrid.