AD
Administrator
Syncfusion Team
September 20, 2004 12:35 PM UTC
Hi Ken,
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.
Stefan
KJ
Ken Johnson
September 20, 2004 01:00 PM UTC
>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.
Ken
AD
Administrator
Syncfusion Team
September 20, 2004 01:03 PM UTC
Hi Ken,
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.
Stefan
AD
Administrator
Syncfusion Team
September 20, 2004 01:25 PM UTC
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.
AD
Administrator
Syncfusion Team
September 20, 2004 02:02 PM UTC
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.
Stefan
KJ
Ken Johnson
September 21, 2004 08:41 AM UTC
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.
Ken
SimpleDependentCombo_7152.zip
AD
Administrator
Syncfusion Team
September 21, 2004 10:09 AM UTC
Hi Ken,
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.
Stefan
SimpleDependentCombo_1806.zip
KJ
Ken Johnson
September 21, 2004 11:37 AM UTC
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.
Ken
AD
Administrator
Syncfusion Team
September 21, 2004 01:02 PM UTC
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.
Stefan
KJ
Ken Johnson
September 21, 2004 03:38 PM UTC
Thanks Stefan. Your last post hooked me up.
Ken
KJ
Ken Johnson
September 23, 2004 04:36 PM UTC
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
Any ideas?
Ken
AD
Administrator
Syncfusion Team
September 23, 2004 06:07 PM UTC
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;
}
AD
Administrator
Syncfusion Team
September 24, 2004 10:07 AM UTC
Hi Ken,
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?
Stefan
AD
Administrator
Syncfusion Team
September 24, 2004 10:38 AM UTC
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.
AD
Administrator
Syncfusion Team
September 24, 2004 10:40 AM UTC
>What version do you have?
2.0.5.0
AD
Administrator
Syncfusion Team
September 24, 2004 10:51 AM UTC
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.
AD
Administrator
Syncfusion Team
September 24, 2004 03:01 PM UTC
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.
Stefan
AD
Administrator
Syncfusion Team
September 24, 2004 03:43 PM UTC
Calling the current cell Validate method before EndEdit in the CloseDropDown handler did the trick.
Thanks.
Ken