We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

GridListControl Columns

Hi, I'm populating a Data Grid with the following code: (bTable is a returned DataTable) GridListControl1.Grid.Model[0,1].CellValue = "ID"; GridListControl1.Grid.Model[0,2].CellValue = "Nome"; GridListControl1.Grid.Model[0,3].CellValue = "Accao"; GridListControl1.Grid.Model.ColCount = 3; GridListControl1.Grid.Model.RowCount = 0; int row = 0; foreach(DataRow bRow in bTable.Rows) { row++; GridListControl1.Grid.Model.RowCount = row; GridListControl1.Grid.Model[row,1].CellValue = bRow[0].ToString(); GridListControl1.Grid.Model[row,2].CellValue = bRow[3].ToString(); GridListControl1.Grid.Model[row,3].CellValue = bRow[4].ToString(); } And the grid is filled with the values i want, but with 255 columns. I dont want to do " GridListControl1.DataSource = bTable; " because i dont want to put all the values of the DataTable (bTable) in the grid. Questions: I would like to create a GridListControl with 3 columns. " GridListControl1.Grid.Model.ColCount = 3; " But doesn't work... it creates a grid with 255 columns. If i try to remove the columns: " GridListControl1.Grid.Model.Cols.RemoveRange ( 5, 255 ); " It doesn´t do anything. Can anyone help me on this, please ?

1 Reply

AD Administrator Syncfusion Team February 26, 2003 06:34 PM UTC

The GridListControl uses the embedded grid in a virtual manner, meaning that it gets all values from Grid.QueryCellInfo on demand, and not from any values stored in the grid. So, you cannot just have code like GridListControl1.Grid.Model[row,col].Text = "abc"; as the grid does not look in its data object for the values. It gets them from QueryCellInfo. So, you should add a handler for GirdListControl.Grid.Model.QueryCellInfo, and in your handle, check the values passed in for e.RowIndex and e.ColIndex. Based on these values, set e.Style.Text to the proper value from the datatable. You can also provide the header when e.RowIndex = 0. Make sure you set e.Handle = true when you actually set values. Also, you can add a handler for QueryColCount and set the count in the event args to 3.

Loader.
Up arrow icon