AD
Administrator
Syncfusion Team
June 9, 2006 05:47 AM UTC
Hi Curtis ,
Could you try this code to add the item(colors) in a dropdown of the grid using the grid''s CurrentCellShowingDropDown event. Here is a code snippet,
private void gridDataBoundGrid1_CurrentCellShowingDropDown(object sender, Syncfusion.Windows.Forms.Grid.GridCurrentCellShowingDropDownEventArgs e)
{
GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer;
if(cr != null )
{
cc.BeginEdit(true);
// DropDown inside Grid
DataTable GridDropDown = cr.ListBoxPart.DataSource as DataTable;
//Outside DropDown DataTable
DataTable ComboTable = this.comboBox1.DataSource as DataTable;
//change the DataSource Depends upon the outside DropDown"
if(ComboTable != null)
{
for(int i = 0 ;i < ComboTable.Rows.Count;i++)
{
DataRow crow = ComboTable.Rows[i];
bool isExist = false;
for(int j = 0 ;j < GridDropDown.Rows.Count;j++)
{
//ColorItem is the DisplayMember of the combo and GridcomboBox.
if(crow["ColorItem"] == GridDropDown.Rows[0]["ColorItem"] )
{
isExist = true;
break;
}
}
if(!isExist)
{
DataRow dr1 = GridDropDown.NewRow();
dr1[1] = crow["ColorItem"];
GridDropDown.Rows.Add(dr1);
}
}
}
cr.ListBoxPart.DataSource = GridDropDown;
cc.EndEdit();
}
}
Let me know if this helps.
Best Regards,
Haneef
CG
Curtis Gulick
June 23, 2006 07:29 PM UTC
Haneef, this worked! Thanks!
>Hi Curtis ,
>
>Could you try this code to add the item(colors) in a dropdown of the grid using the grid''s CurrentCellShowingDropDown event. Here is a code snippet,
>
>private void gridDataBoundGrid1_CurrentCellShowingDropDown(object sender, Syncfusion.Windows.Forms.Grid.GridCurrentCellShowingDropDownEventArgs e)
>{
> GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
> GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer;
>
> if(cr != null )
> {
> cc.BeginEdit(true);
>
> // DropDown inside Grid
> DataTable GridDropDown = cr.ListBoxPart.DataSource as DataTable;
>
> //Outside DropDown DataTable
> DataTable ComboTable = this.comboBox1.DataSource as DataTable;
>
> //change the DataSource Depends upon the outside DropDown"
> if(ComboTable != null)
> {
> for(int i = 0 ;i < ComboTable.Rows.Count;i++)
> {
> DataRow crow = ComboTable.Rows[i];
> bool isExist = false;
> for(int j = 0 ;j < GridDropDown.Rows.Count;j++)
> {
> //ColorItem is the DisplayMember of the combo and GridcomboBox.
> if(crow["ColorItem"] == GridDropDown.Rows[0]["ColorItem"] )
> {
> isExist = true;
> break;
> }
> }
> if(!isExist)
> {
> DataRow dr1 = GridDropDown.NewRow();
> dr1[1] = crow["ColorItem"];
> GridDropDown.Rows.Add(dr1);
> }
> }
> }
> cr.ListBoxPart.DataSource = GridDropDown;
> cc.EndEdit();
> }
>}
>
>Let me know if this helps.
>Best Regards,
>Haneef