We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

change dropdown list content based on current record.

I need to change a content of dropdown list in my grouping control based on the current record.
Here is what I did:
1. I bound dropDown list column for each group level to listSource
grid.Engine.SourceListSet.Add("UserActions", dvActions);
2. Added myControlo_TableControlCurrentCellShowingDropDown event to catch when user clicks the dropdown.
3. use CurrentCell value in the event to identify what control (what column) was clicked.
int ColIndex = ((Syncfusion.Windows.Forms.Grid.Grouping.GridGroupingControl)(sender)).TableControl.CurrentCell.ColIndex;

5. Use ColIndex to identify column name to decide what function to call for the given control.

string tableName = ((GridTableControlCurrentCellShowingDropDownEventArgs)e).TableControl.Table.CurrentRecord.ParentChildTable.Name;

string colName = ((Syncfusion.Windows.Forms.Grid.Grouping.GridGroupingControl)(sender)).GetTableDescriptor(tableName).Columns[ColIndex].Name;

6. change Filter value based on the current record and clicked control:
string filerValue ="RuleID = ''" + ((Syncfusion.Windows.Forms.Grid.Grouping.GridGroupingControl)(sender)).Table.CurrentRecord.GetValue("_ruleID").ToString() + "''";
dvActions.RowFilter = filerValue;

My problem is that ColIndex value not always what I expect it would be. Therefor colIndex translation to column name not always work!!!
Does anybody knows how to convert current cell index to a currect datacolumn index???

1 Reply

AD Administrator Syncfusion Team September 12, 2006 08:45 AM UTC

Hi Michael,

Use this code snippet to get the current column information in TableControlCurrentCellShowingDropDown event.

int index = e.TableControl.TableDescriptor.ColIndexToField(e.TableControl.CurrentCell.ColIndex);

Console.WriteLine("Current Column Name : " + e.TableControl.TableDescriptor.VisibleColumns[index].Name );

Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon