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
close icon

GridGroupingControl CellType

Hi. I have a text column in my datasource and I need display this column values different ways depend on a correspond values in another column. So I try this: private void gridGroupingControl1_QueryCellStyleInfo( object sender, GridTableCellStyleInfoEventArgs e ) { if ( e.TableCellIdentity.Column != null && e.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record && e.TableCellIdentity.Column.Name == "Value" ) { DataRowView row = (DataRowView)e.TableCellIdentity.DisplayElement.GetData(); switch ( (Byte)row["ValueType"] ) { case 2 : e.Style.CellValueType = typeof(DateTime); e.Style.CellType = "MonthCalendar"; break; case 3 : e.Style.CellValueType = typeof(int); e.Style.CellType = "ComboBox"; e.Style.ExclusiveChoiceList = true; e.Style.DisplayMember = "Text"; e.Style.ValueMember = "Id"; e.Style.DataSource = MyListItem.GetDataSource(); break; default: e.Style.CellType = "TextBox"; break; } e.Handled = true; } } It''s work normal when I click in combo-cell (case 3). But when I leave my combo-cell it displays empty value.

4 Replies

AD Administrator Syncfusion Team August 26, 2005 11:46 AM UTC

Are you seeing any exceptions being displayed in your output window as you move off the cell? You may have to handle SaveCellStyleInfo, and in this case, make sure the proper value is being saved. If you just want to change how teh text is displayed, you can use TableControlDrawCellDisplayText and avoid working with QueryCellStyleInfo and SaveCellStyleInfo.


DM Dmitry August 29, 2005 03:10 AM UTC

1. I am not seeing exceptions. 2. I can''t find SaveCellStyleInfo event if search over all Studio Documentation. 3. I sure the proper value is being saved because this cell displays last assigned selection next time I click it. 4. I not only want change how text is displayed but I need change way how it assigned (like typed columns).


AD Administrator Syncfusion Team August 29, 2005 07:43 AM UTC

I am sorry. I should have written SaveCellFormattedText instead of SaveCellStyleInfo. Here is a sample that does everything in QueryCellStyleInfo. http://www.syncfusion.com/Support/user/uploads/GGC_CellTypesChangeWithColumnValue_871dc1f7.zip The one tricky part is what do you want to happen if the cell is a TextBox with ABC in it, and your user changes the value in the other column so the cell now should be a DateTime. In this case, your DataSource still has ABC in it, but this value does not represent a valid DateTime. The sample tries to catch these problems using either double.TryParse or just a try-catch, and then changes the value to someproper default.


DM Dmitry August 29, 2005 08:36 AM UTC

Your DataTable Value column is Object type while my is Varchar. But seeing your example code I try assign value to e.Style.CellValue in each query. It solve my problem. Thank you very much! And sorry for my English. :)

Loader.
Live Chat Icon For mobile
Up arrow icon