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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Changing Cell Type in GDBG

Thread ID:





37031 Nov 15,2005 04:29 AM UTC Nov 15,2005 09:06 PM UTC Windows Forms 10
Tags: GridControl
Administrator [Syncfusion]
Asked On November 15, 2005 04:29 AM UTC

Hi I have a cell which has ‘ComboBox’ as CellType, as soon I change/pick a different value for that cell, I need to change the CellType of certain cells in same row. I need to make some cells as ’PushButton” or some as checkbox. Which event is the best for this kind of formatting? If there is a sample where I could look into that perform this sort of functionality that would be great. Your help would be much appreciated. Thanks, Rick

Administrator [Syncfusion]
Replied On November 15, 2005 07:59 AM UTC

Hi Rick, You can try handling CurrentCellCloseDropDown event handler. Please refer this code snippet: private void Model_QueryCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e) { GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell; if(flag==1 && e.ColIndex>1 && e.ColIndex<=4 && e.RowIndex==row ) { e.Style.CellType="PushButton"; } if(flag==1 && e.ColIndex>=5 && e.ColIndex<=10 && e.RowIndex==row ) { e.Style.CellType="CheckBox"; } } int flag=0; int row; private void gridDataBoundGrid1_CurrentCellCloseDropDown(object sender, Syncfusion.Windows.Forms.PopupClosedEventArgs e) { GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell; if(cc.ColIndex == 1 ) { flag=0; row=cc.RowIndex; GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer; if (cr.ControlText == "") flag = 0; else flag = 1; } } Here is the sample. ComboDropDownCellType.zip Let us know if this helps. Best Regards, Jeba.

Administrator [Syncfusion]
Replied On November 15, 2005 08:15 AM UTC

Why can''t i use the PrepareViewStyleInfo event somehow? unless this is not the right place to do it. i have code in place, if i picking a different value from combox could trigger PrepareViewStyleInfo event the everything should be fine. even the sample provided by you have refresh issue, it doesn''t change the style until i cliked somewhere else on the grid. Waiting for the reply! Rick

Administrator [Syncfusion]
Replied On November 15, 2005 08:49 AM UTC

There are some things that require the use of QueryCellInfo instead of PrepareViewStyleInfo. These are things that affect the non-visual nature of the cell. For example, trying to set style.ReadOnly works in QueryCellInfo but not in PrepareViewStyleInfo. QueryCellInfo is raised earlier in the process and is the first place you can adjust the style of a cell dynamically. PrepareViewStyle is raised after QueryCellInfo, right before the style is passed into the drawing routines. It gives you a chance to modify the style only during the drawing process. Here is a KB link on this. http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=96

Administrator [Syncfusion]
Replied On November 15, 2005 06:15 PM UTC

Clay, i copied all the code from the prepareviwestyleinfo to the Model_QueryCellInfo event. NOw i even don''t see the combobox. because i was preparing the combobox in prepareviwestyleinfo event itself. I have registered the event in form_load using the followin code this.grid.Model.QueryCellInfo+=new Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventHandler(Model_QueryCellInfo); Rick,

Administrator [Syncfusion]
Replied On November 15, 2005 06:41 PM UTC

It is probably easier to think about this process not as the combobox setting the button cell, but instead think of it this way. When you want to draw/use the button cell, what does the combobox indicate it should be? Here is a little sample that has a combobox column and the value of teh combobox determines whether the cell next to it is a button or a text cell. http://www.syncfusion.com/Support/user/uploads/GDBG_ComboSwap_85efafe7.zip

Administrator [Syncfusion]
Replied On November 15, 2005 07:01 PM UTC

This is exactly how I coded but these two lines did the Job. this.gridDataBoundGrid1.CurrentCell.EndEdit(); this.gridDataBoundGrid1.Binder.EndEdit(); I have attached a sample file that contains the code from Model_QueryCellInfo event. Now refresh of the grid is very very slow. Please suggest something keeping in mind these two condition. I am using grid in a hierarchical view. #1 I don''t need the comboBox on each cell of a column, only cells of a child row have cell type of ‘combobox’ #2 There are two sets of data tables are being used as data source for the source of comboxbox for A COLUMN. That is why I can''t assign cell type as ''combobox'' for a column. Please suggest something. Thanks,


Administrator [Syncfusion]
Replied On November 15, 2005 07:15 PM UTC

Optimizing your code is about the only way to speed this up. You have a series of if''s where the true alternaives are mutually exclusive. You should change these to if-else''s to avoid hitting later if-statements after a true condition is encountered. For your combobox column, it looks like you always have one of 2 alternatives. You could try setting the GridBoundColumn.StyleInfo for that column to have the proprties of the alternative you think will occur more often. Then you would only have to set the one case in QueryCellStyleInfo.

Administrator [Syncfusion]
Replied On November 15, 2005 07:25 PM UTC

How do I use GridBoundColumn.StyleInfo in case of hierarchical view where I need combo box for only child rows? Few lines of code would be great help. rick,

Administrator [Syncfusion]
Replied On November 15, 2005 08:14 PM UTC

You use the HierarchlyLevel object. GridHierarchyLevel level1 = gridDataBoundGrid1.Binder.AddRelation("ParentToChild")); level1.InternalColumns["col1"].StyleInfo.BackColor = Color.Red; (You use the level.InternalColumns collection if you do not explicitly add GridBoundColumns to the level.GridBoundColumns collection. Other wise, you use the level.GridBoundColumns collection).

Administrator [Syncfusion]
Replied On November 15, 2005 09:06 PM UTC



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.

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