User (Old forums)MemberNovember 5, 2008 at 8:35 amPost count: 23064
I’m kind of embaressed to ask this but I see no other way to solve this since I can’t find an answer to my problem on the internet.
Actually it is something very simple but I’m not being able to do it.
I’ve a DataTable that came from my database and then binded it to an Xceed Grid through DataSource
Ex: myXceedGrid.DataSource = Mytable;
Now, my problem is that when I test it I’ve noticed that it doesn’t show the header row with the title of each column. To solve this problem I thought that it would be easy, something like myGrid.HeaderRows.Add(“Column1”, “Column2″…) But that isn’t possible.
I tried creating a DataRow and add DataCells with the column names but I keep getting an error that tells me that it is not possible to add something to a ReadOnly or FixedSize row… I setted ReadOnly to False and it didn’t work. Didn’t find a FixedSize property though…
Well… that is my problem…
What I need is just a way to solve this… or an explanation/code to create a headerRow dynamically.
Could anyone help me ?
Thanks in advance.
Imported from legacy forums. Posted by Oscar (had 1159 views)User (Old forums)MemberNovember 5, 2008 at 3:35 pmPost count: 23064
Simply use the ColumnManagerRow class :
ColumnManagerRow managerRow = new ColumnManagerRow();
gridControl1.FixedHeaderRows.Add( managerRow );
BTW, an easy way to find out how to do things in code is to do it through the designer in a sample project, and look at the code that is generated. Then reproduce this code in your actual project.
Imported from legacy forums. Posted by André (had 364 views)User (Old forums)MemberNovember 6, 2008 at 6:30 amPost count: 23064
I tried to do what you’ve told me to, but I’m getting the readonly or fixed size error.
Here, take a look at my code
ColumnManagerRow cmrHeader = new ColumnManagerRow(); // Header Row
//Reading the column names from the table and copying to the header row
foreach (System.Data.DataColumn col in dtbActualTable.Columns)
if (MyResource.ResourceManager.GetString(col.ColumnName) != null)
if (col.ColumnName == “Tax”)
Xceed.Grid.DataCell cell = new Xceed.Grid.DataCell(“Tax (% a.a.)”);
cmrHeader.Cells.Add(cell); // ERROR: Cannot add an item to a ReadOnly or FixedSize list.
cell.Value = “Tax (% a.a.)”;
//Here i tried a different method.
cmrHeader.Cells.Add(new Xceed.Grid.DataCell(MyResource.ResourceManager.GetString(col.ColumnName))); // ERROR: Same error above
Do you know what am I doing wrong ?
Thanks in advance
Imported from legacy forums. Posted by Oscar (had 424 views)User (Old forums)MemberNovember 6, 2008 at 2:31 pmPost count: 23064
Only add the two lines of code I provided, and remove everything else you added in your code. When calling the ColumnManagerRow constructor, it will automatically create all the ColumnManagerCell’s for the corresponding columns present in the gird. Remember that when binding the grid, it automatically creates the columns that correspond to those present in the data source.
Imported from legacy forums. Posted by André (had 314 views)User (Old forums)MemberNovember 12, 2008 at 9:42 amPost count: 23064
Thank you for your attention andré! I’ll try to do that as soon as I get my GridControl working.
Since I’m having a problem with another thing I’ll create another topic about it
This is the link,
Thanks again André!
Imported from legacy forums. Posted by Oscar (had 1047 views)
- You must be logged in to reply to this topic.