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

GDBG (3.2.1) and changing cell type dynamically

Hi, Is there any efficient way to change the cell type dynamically ? I am using the QueryCellInfo event to change the cell type but I am getting some display problems (please see doc file in attachment). Any idea what could be wrong ? Thanks for your help, Michael GDBG_2376.zip

9 Replies

AD Administrator Syncfusion Team July 22, 2005 11:00 AM UTC

QueryCellInfo is the way to change celltypes on a cell by cell basis in a GridDataBoundGrid. Are you saying that you want to dynamically change a cell from textbox to combobox? ie., a particular row, col value is a double one instant, and then the next instant, it is a guid? If you make this change outside the grid in your datasource, then calling grid.RefreshRange and passing in the cell range should allow this to work I think. But if you are letting your user change the value from a double to a guid, then that is more difficult. The reason is that as the user starts to edit teh cell, then cell control is initialzed through the style (and QueryCellInfo). But once the editing cell control is setup, then that is the type of control that is in teh cell. And you would not be able to change that unless you deactivated and reactivated the current cell so it could then be initialized with the new type of control. If you can upload a little sample showing the problem, we can probably suggest a way to handle it.

MC Michael Cruanes July 22, 2005 03:30 PM UTC

Not exactly Clay. Let say that I have a column containing a data type information about the data to edit. When changing row, I want a TextBox as celltype for double data or a ComboBox for Guid data. The user does not choose the celltype. It is given by a specific column. Is it clear enough ?

AD Administrator Syncfusion Team July 22, 2005 04:46 PM UTC

Suppose your datasource has a guid in it. And all of a sudden, your user changes the ''trigger'' cell so that this guid cell should now be a double. What is supppose to happen at this point? Does the double cell display some defaultvalue? The guid that was there cannot stay there as a guid is not a valid double. Are you trying to handle this point? If not, then I suspect this is why things are behaving strangely for you. Here is a little sample that tries to handle this. http://www.syncfusion.com/Support/user/uploads/GGC_DynamicCells_3b365848.zip

MC Michael Cruanes July 25, 2005 12:18 PM UTC

Hi Clay, Thank you for support. Beside this celltype issue, I have some trouble to access the dataset within QueryCellInfo event. I get following message: "There is already an open DataReader associated with this Connection which must be closed first.". How can I get the value of dataset columns using e.RowIndex ?

AD Administrator Syncfusion Team July 25, 2005 12:52 PM UTC

As far as I know, you will not be able to use a DataReader in QueryCellInfo. The reason is that a DataReader does not do random access reads. It is a sequential read from start to finish. You will need to store the information in a datastucture that supports random access as QueryCellInfo needs to be able to continually access the data. If you have initially used a DataReader to access the data, have you tried closing it after you have loaded the data?

MC Michael Cruanes July 26, 2005 06:41 AM UTC

I am not using a datareader at all. I think it is a sharing problem of the dataset. The grid uses the dataset. It seems that within QueryCellInfo I cannot access the dataset. Any idea ?

AD Administrator Syncfusion Team July 26, 2005 07:30 AM UTC

Not really. Just as a test, can you try using the code in a button handler? I suspect you will not be able to use the code there either? Can you post the code you have in QueryCellInfo? The only thing special about QueryCellInfo is that it is hot a lot. You normally do not put times consuming code like database accesses in that event. If all you are trying to do is to get a reference to a particular table in dataSet.Tables (or something else of that nature), then I think it should work ok. But if you are trying to do a dataadapter.Fill or DataSet.Merge or something of that nature, then QueryCellInfo is not a good place.

MC Michael Cruanes July 27, 2005 08:42 AM UTC

The code I have in QueryCellInfo is in attachment. In fact I need to fill the dataset related to the combobox cell. The dataset fill is done within QueryCellInfo. If you know a better place, please tell me. But this has nothing to do with the dataset sharing problem. To solve that, I added 2 other grid columns and I get the data through grid cell. It is working, but I would prefer to get it from the dataset. QueryCellInfo_4286.zip

AD Administrator Syncfusion Team July 27, 2005 09:06 AM UTC

I would try to set these properties on the GridBoundColumn.StyleInfo in Form.Load or the form''s constructor. e.Style.DataSource = this.dsRelParEnumItem1.RelParEnumItem_Sel; e.Style.DisplayMember = "EnumText"; e.Style.DropDownStyle = GridDropDownStyle.Exclusive; e.Style.ShowButtons = GridShowButtons.Show; e.Style.ValueMember = "RelParEnumItemID"; They would be ignored until you set e.Style.CellType = "ComboBox" in QueryCellInfo.

Live Chat Icon For mobile
Up arrow icon