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

populate content of combobox according another combox picked value

Hello, On GridGroupingcontrol, I have two columns Table Name and Field Name, both are combobox dropdown list. I want to populate the content of field name combobox with the fields of table picked from table combobox. Any sample codes? lan

5 Replies

AD Administrator Syncfusion Team May 30, 2005 03:18 PM

Try using the this.gridGroupingControl1.TableControlCurrentCellShowingDropDown event to set the second dropdown''s datasource. Here is a KB showing how to do this in a GridDataBoundGrid. The gridGroupingControl should be similar. http://www.syncfusion.com/Support/article.aspx?id=567


LM Lan Mo May 31, 2005 10:47 AM

Hello, I try to replace the two events in GridGroupingControl. How I replace this line this.gridDataBoundGrid1[cc.RowIndex, SlaveColumn].Text = ""; besides, I want to use Column Name instead of ColumnIndex to identify master/slave columns because my form dynamicaaly load the field with user definied orders. Thanks, Lan >Try using the this.gridGroupingControl1.TableControlCurrentCellShowingDropDown event to set the second dropdown''s datasource. Here is a KB showing how to do this in a GridDataBoundGrid. The gridGroupingControl should be similar. >http://www.syncfusion.com/Support/article.aspx?id=567


AD Administrator Syncfusion Team May 31, 2005 11:58 AM

Try code like this:
private void gridGroupingControl1_TableControlCurrentCellShowingDropDown(object sender, GridTableControlCurrentCellShowingDropDownEventArgs e)
{
	GridCurrentCell cc = e.TableControl.CurrentCell;
	GridTableCellStyleInfo style = e.TableControl.Model[cc.RowIndex, cc.ColIndex];
	GridRecord rec = style.TableCellIdentity.DisplayElement as GridRecord;
	if(rec != null)
	{
		rec.SetValue("theColumnName") = "";
	}
}


LM Lan Mo May 31, 2005 12:10 PM

I tried. the object "rec" always null. >Try code like this: >
>private void gridGroupingControl1_TableControlCurrentCellShowingDropDown(object sender, GridTableControlCurrentCellShowingDropDownEventArgs e)
>{
>	GridCurrentCell cc = e.TableControl.CurrentCell;
>	GridTableCellStyleInfo style = e.TableControl.Model[cc.RowIndex, cc.ColIndex];
>	GridRecord rec = style.TableCellIdentity.DisplayElement as GridRecord;
>	if(rec != null)
>	{
>		rec.SetValue("theColumnName") = "";
>	}
>}
>


LM Lan Mo May 31, 2005 01:15 PM

Hello, I used underline datasource to get the field data. Now it works OK for master/slave combobox on grigroupingcontrol. Thanks for help. Here is my code in the two events. //change slave combobox list according master combobox value private void gdBase_TableControlCurrentCellShowingDropDown(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCurrentCellShowingDropDownEventArgs e) { GridCurrentCell cc = e.TableControl.CurrentCell; int ind=gdBase.Table.UnsortedRecords.IndexOf(this.gdBase.Table.CurrentRecord); if (ind<0) return; //ind=-1 no record DataRow dr = mGridDataSet.Tables[0].Rows[ind]; // underline datasource //1. TABLE DICT_FIELD if (mFormParam.TableName.ToUpper()=="DICT_FIELD") { string sName=gdBase.TableDescriptor.Columns[cc.ColIndex-1].Name.ToUpper(); if (sName=="LOOKUP_FIELD_CODE" || sName=="LOOKUP_FIELD_VAL" || sName=="LOOKUP_FLTR_FIELD" ) { GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer; if(cr != null) { //cc.ConfirmChanges(false); string sWhere = string.Format("TABLE_NAME = ''{0}''", dr["lookup_table"].ToString()); DataSet dsFldList=BL.Access.LoadDataSet("DICT_FIELD","FIELD_NAME",sWhere); cr.ListBoxPart.DataSource=dsFldList.Tables["DICT_FIELD"]; cr.ListBoxPart.DisplayMember ="FIELD_NAME"; cr.ListBoxPart.ValueMember ="FIELD_NAME"; } } return; } } // empty salve combobox when master combobox changed private void gdBase_TableControlCurrentCellChanged(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlEventArgs e) { GridCurrentCell cc = e.TableControl.CurrentCell; int ind=gdBase.Table.UnsortedRecords.IndexOf(this.gdBase.Table.CurrentRecord); if (ind<0) return; //ind=-1 no record DataRow dr = mGridDataSet.Tables[0].Rows[ind]; // underline datasource //1. TABLE DICT_FIELD - master/slave combobox if (mFormParam.TableName.ToUpper()=="DICT_FIELD") { if (gdBase.TableDescriptor.Columns[cc.ColIndex-1].Name.ToUpper()=="LOOKUP_TABLE" ) { cc.ConfirmChanges(false); dr["LOOKUP_FIELD_CODE"]= ""; dr["LOOKUP_FIELD_VAL"]= ""; dr["LOOKUP_FLTR_FIELD"]= ""; dr["LOOKUP_FLTR_VAL"]= ""; } return; } } >Try code like this: >
>private void gridGroupingControl1_TableControlCurrentCellShowingDropDown(object sender, GridTableControlCurrentCellShowingDropDownEventArgs e)
>{
>	GridCurrentCell cc = e.TableControl.CurrentCell;
>	GridTableCellStyleInfo style = e.TableControl.Model[cc.RowIndex, cc.ColIndex];
>	GridRecord rec = style.TableCellIdentity.DisplayElement as GridRecord;
>	if(rec != null)
>	{
>		rec.SetValue("theColumnName") = "";
>	}
>}
>

Loader.
Live Chat Icon For mobile
Up arrow icon