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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridListControl Columns

Thread ID:





3034 Feb 26,2003 06:10 PM UTC Feb 26,2003 06:34 PM UTC WinForms 1
Tags: GridControl
Jose Luis Melo
Asked On February 26, 2003 06:10 PM UTC

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 ?

Administrator [Syncfusion]
Replied On 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.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon