I have a grid with two columns that contain comboboxes. The combobox list of the first column is static for all rows. The list displayed for the second combobox is dependent on the selection made in the first and is handled in the CurrentCellMoved event. My problem is when the user selects multiple rows in the grid and makes a selection from the second combobox, the row that contains the CurrentCell displays the correct selection but the other rows do not. I believe that second combobox list for the non-CurrentCell rows is not being reloaded, since the control renderer is accessed through the CurrentCell. Is there a way to access the control renderer without using the CurrentCell? Or can you think of a better way to do this?
ADAdministrator Syncfusion Team September 20, 2004 07:35 AM
The cleanest solution would be to assign the correct datasource based on the other columns field to style.DataSource in the QueryStyleInfo event handler.
Another idea would be to handle the CurrentCellActivating event and set the listbox just before it is displayed.
KJKen JohnsonSeptember 20, 2004 08:00 AM
>The cleanest solution would be to assign the correct datasource based on the other columns field to style.DataSource in the QueryStyleInfo event handler.
We abandoned QueryCellInfo for loading dependent combobox lists because it is just too slow.
>Another idea would be to handle the CurrentCellActivating event and set the listbox just before it is displayed.
What will CurrentCellActivating get me that CurrentCellMoved doesn''t? That is where I''m currently doing what you suggest.
ADAdministrator Syncfusion Team September 20, 2004 08:03 AM
CurrentCellActivating will be called before the combobox cell is activated. It will be called for every row.
With CurrentCellMoved on the other side there is a chance that the user selects something on one row and then jumps to a cell in another row. At the time CurrentCellMoved is called you simply don''t know what the next step is for the user.
ADAdministrator Syncfusion Team September 20, 2004 08:25 AM
But isn''t the current cell required to set the DataSource, DisplayMember, and ValueMember for the combobox list? It was my understanding the CurrentCellActivating is fired before the current cell is set.
I was doing all this in CurrentCellShowingDropDown, but I discovered that a user could not utilize the AutoComplete feature since the list was not dropped.
ADAdministrator Syncfusion Team September 20, 2004 09:02 AM
At the time CurrentCellActivating is called there is no current cell and the next step will be to initialize the current cell. The EventArgs contained the row and column index of the future current cell.
So, if you set the DataSource, DisplayMember, and ValueMember at that time, the current cell initialization code should pick those values up when it gets initialzed.
Combined with a QueryCellInfo approach you could try to save those settings when CurrentCellActivating is called and then return them in QueryCellInfo.
KJKen JohnsonSeptember 21, 2004 03:41 AM
Here is a small sample of what I am trying to do. Add three of four rows in the grid with the same finish but different colors. Now select all the added rows and revise all the colors to be the same. The color cell that is selected is correct, the others display the wrong value. Using QueryCellInfo is not an option for us because of how much that event slows down the application. Any insights into accomplishing a multi-select edit would be appreciated.
ADAdministrator Syncfusion Team September 21, 2004 05:09 AM
Attached find the modified sample with CurrentCellActivating caching the values and QueryCellInfo returning the cached values for the current cell. QueryCellInfo should not cause any performance penalty at all - the key is the caching.
KJKen JohnsonSeptember 21, 2004 06:37 AM
Thanks for the sample Stefan. I now see what you were talking about. The only problem now is that it doesn''t solve the original problem. When I take your code and input several rows with different colors, select all the rows and revise the color only the selected row is changed. The rest of the selected rows stays the original input color.
ADAdministrator Syncfusion Team September 21, 2004 08:02 AM
Ok, I didn''t understand the part about the selected rows before ...
For that you could handle CurrentCellCloseDropDown and call CurrentCell.EndEdit so that the change is saved into the current cell.
Then you also handle CurrentCellEditingComplete and loop through the selected cells and assign the style.Text to the other cells.
KJKen JohnsonSeptember 21, 2004 10:38 AM
Thanks Stefan. Your last post hooked me up.
KJKen JohnsonSeptember 23, 2004 11:36 AM
Next problem. I have added a handler for the CurrentCellValidating event. Now I am getting an exception when I set the CancelEventArg Cancel property to true. If I remove the cancel property, no exception but the user can leave the screen with invalid data.
The sequence of events is:
in the CurrentCellCloseDropdown event - EndEdit is called.
in the CurrentCellValidating event - cancel property is set to true.
the exception is being thrown from the EndEdit
ADAdministrator Syncfusion Team September 23, 2004 01:07 PM
All you have to do is add the following event to your sample and you will see the exception.
private void grdList_CurrentCellValidating(object sender, CancelEventArgs e)
e.Cancel = true;
ADAdministrator Syncfusion Team September 24, 2004 05:07 AM
I added those lines but it works fine for me.
What version do you have?
Does it help if you call CancelEdit instead of EndEdit in the case that you know you want to set e.Cancel = false anyway?
ADAdministrator Syncfusion Team September 24, 2004 05:38 AM
I''ll try calling CancelEdit to see if that makes a difference. To test it, I just added the validating handler to the sample that you posted and then selected an item from a combobox list.
ADAdministrator Syncfusion Team September 24, 2004 05:40 AM
>What version do you have?
ADAdministrator Syncfusion Team September 24, 2004 05:51 AM
One problem with calling CancelEdit is the sequence in which events are executed. The CurrentCellCloseDropdown, which contains the EndEdit call is executed before the CurrentCellValidating event, where the cancel property is set. I tried calling CancelEdit in the validating property, but the EndEdit method is already called and I still get the exception.
ADAdministrator Syncfusion Team September 24, 2004 10:01 AM
What if you try to call CurrentCell.Validate() from your DropDown handler and then check the CurrentCell.IsValid property. If it is false you don''t call EndEdit.
ADAdministrator Syncfusion Team September 24, 2004 10:43 AM
Calling the current cell Validate method before EndEdit in the CloseDropDown handler did the trick.