Hi Vaibhav,
Thanks for the update.
You could achieve the desired behavior in combo box cell by handling the PrepareViewStyleInfo event with the following code. Here I have created two methods named “IntersectCollection()” and “GetCellValues()” to filter the cell values.
this.gridGroupingControl1.TableControlPrepareViewStyleInfo += new GridTableControlPrepareViewStyleInfoEventHandler(gridGroupingControl1_TableControlPrepareViewStyleInfo);
void gridGroupingControl1_TableControlPrepareViewStyleInfo(object sender, GridTableControlPrepareViewStyleInfoEventArgs e)
{
GridTableCellStyleInfoIdentity id = this.gridGroupingControl1.TableModel[e.Inner.RowIndex, e.Inner.ColIndex].CellIdentity as GridTableCellStyleInfoIdentity; if(id.Column!=null && id.Column.Name.Equals("Year"))
{
e.Inner.Style.ChoiceList = IntersectCollection();
}
}
public StringCollection IntersectCollection()
{
int row, col;
this.gridGroupingControl1.TableDescriptor.ColumnToRowColIndex("Year", out row, out col);
StringCollection str = new StringCollection();
StringCollection s = GetCellValues(col + 1);
if (s.Count > 0)
{
foreach (string st in year)
{
if (!s.Contains(st) && !str.Contains(st))
str.Add(st);
}
}
return str;
}
public StringCollection GetCellValues(int colIndex) // separate the available choices
{
StringCollection str1 = new StringCollection();
if (this.gridGroupingControl1.TableModel.CurrentCellInfo != null)
{
for (int i = 3; i < this.gridGroupingControl1.TableModel.RowCount + 1; i++)
{
string value = "";
if (this.gridGroupingControl1.TableModel[i, colIndex].CellValue != null)
value = this.gridGroupingControl1.TableModel[i, colIndex].CellValue.ToString();
str1.Add(value);
}
}
return str1;
}
Please refer the following sample which illustrates the above.
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GGC_Separate528536529.zipPlease let me know if you have any other concerns.
Regards,
Christopher K.