Hi,
I have a combo in one of the cells in the grid (unbound).
I want to limit the selectable items to only those that satisfy a condition.
The items in the combo look something like this:
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Item 7
In this example I''d only like Item 3, 4, 6 and 7 to be selectable.
Thanks,
Nick
AD
Administrator
Syncfusion Team
February 11, 2005 12:13 PM UTC
Hi Nick,
one idea would be to derive a cell type from ComboBoxCellRenderer class and override the following methods:
object oldValue;
protected override void OnShowDropDown()
{
oldValue = ControlValue;
base.OnShowDropDown ();
}
protected override void OnCloseDropDown(PopupCloseType reason)
{
base.OnCloseDropDown (reason);
string s = ControlText;
if (s == "Item3" || s == "Item4")
{
; // accept entry
}
else
{
ControlValue = oldValue;
}
}
public override bool ValidateString(string s)
{
if (s == "Item3" || s == "Item4")
{
// accept entry
}
else
return false;
return base.ValidateString(s);
}
>Hi,
>
>I have a combo in one of the cells in the grid (unbound).
>
>I want to limit the selectable items to only those that satisfy a condition.
>
>The items in the combo look something like this:
>
>Item 1
> Item 2
> Item 3
> Item 4
> Item 5
> Item 6
> Item 7
>
>In this example I''d only like Item 3, 4, 6 and 7 to be selectable.
>
>Thanks,
>
>Nick
NZ
Nick Zdunic
February 14, 2005 07:44 AM UTC
How is this used in client code?
>Hi Nick,
>
>one idea would be to derive a cell type from ComboBoxCellRenderer class and override the following methods:
>
>
> object oldValue;
> protected override void OnShowDropDown()
> {
> oldValue = ControlValue;
> base.OnShowDropDown ();
> }
>
> protected override void OnCloseDropDown(PopupCloseType reason)
> {
> base.OnCloseDropDown (reason);
> string s = ControlText;
> if (s == "Item3" || s == "Item4")
> {
> ; // accept entry
> }
> else
> {
> ControlValue = oldValue;
> }
> }
>
> public override bool ValidateString(string s)
> {
> if (s == "Item3" || s == "Item4")
> {
> // accept entry
> }
> else
> return false;
>
> return base.ValidateString(s);
> }
>
>
>
>>Hi,
>>
>>I have a combo in one of the cells in the grid (unbound).
>>
>>I want to limit the selectable items to only those that satisfy a condition.
>>
>>The items in the combo look something like this:
>>
>>Item 1
>> Item 2
>> Item 3
>> Item 4
>> Item 5
>> Item 6
>> Item 7
>>
>>In this example I''d only like Item 3, 4, 6 and 7 to be selectable.
>>
>>Thanks,
>>
>>Nick
AD
Administrator
Syncfusion Team
February 14, 2005 09:42 AM UTC
To use this technique, you would have to derive your own combobox cell control (deriving both GridComboBoxCellModel and GridComboBoxCellRenderer). In your renderer derived class, you would override the methods listed above.
Another option that might work (if it suites your purpose) without deriving your own cell control would be to handle the CurrentCellShowingDropDown event. There you could just remove the values fdrom the droplist that you do not want to see. Then they would not be selectable as they would not appear in the droplist. Here is a link to a KB article that shows something similar. http://www.syncfusion.com/Support/article.aspx?id=567
NZ
Nick Zdunic
February 14, 2005 11:01 AM UTC
I need the items to be visible still, so the first method seems better.
How does client code use the derived classes. How do I get the grid to use the derived class. Can you please supply some sample code for this.
>To use this technique, you would have to derive your own combobox cell control (deriving both GridComboBoxCellModel and GridComboBoxCellRenderer). In your renderer derived class, you would override the methods listed above.
>
>Another option that might work (if it suites your purpose) without deriving your own cell control would be to handle the CurrentCellShowingDropDown event. There you could just remove the values fdrom the droplist that you do not want to see. Then they would not be selectable as they would not appear in the droplist. Here is a link to a KB article that shows something similar. http://www.syncfusion.com/Support/article.aspx?id=567
AD
Administrator
Syncfusion Team
February 14, 2005 11:18 AM UTC
There is a section in the User Guide, Essential Grid\Features in Depth\Deriving a Cell Control that discusses deriving your own cell control.
We ship 20+ samples of derived cell controls. (Do a search for CellModels.Add in the sample folder). The calendarcells sample in this folder is one such: Syncfusion\Essential Suite\3.0.1.0\Windows\Grid.Windows\Samples\CellTypes
AD
Administrator
Syncfusion Team
February 14, 2005 11:42 AM UTC
You can also probably do this using events without deriving a cell control. Here is a try at this using the CurrentCellShowingDropDown and the CurrentCellCloseDropDown events.
http://www.syncfusion.com/forums/Uploads/GC_Combo_forum1.zip
NZ
Nick Zdunic
February 14, 2005 01:07 PM UTC
This method works very well.
>There is a section in the User Guide, Essential Grid\Features in Depth\Deriving a Cell Control that discusses deriving your own cell control.
>
>We ship 20+ samples of derived cell controls. (Do a search for CellModels.Add in the sample folder). The calendarcells sample in this folder is one such: Syncfusion\Essential Suite\3.0.1.0\Windows\Grid.Windows\Samples\CellTypes