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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ComboBox .DataSource be dependent on spezific row value

Thread ID:





2633 Feb 6,2003 10:32 AM UTC Feb 7,2003 04:20 AM UTC WinForms 2
Tags: GridControl
Markus Kraft
Asked On February 6, 2003 10:32 AM UTC

Hi, The rows in column number 2 includes in my datatable the string "command" or "measurand". The checkbox in the column "Type" should have by "command" the values "DC" and "SC",and by "measurand" they should have the values "SP" and "DP". It is possible to fill and display a combobox, at the moment they will clicked ("just in time value changing")? Here some code snipets: CommandItems = new StringCollection(); CommandItems.Add("SC"); CommandItems.Add("DC"); MeasurandItems = new StringCollection(); MeasurandItems.Add("SP"); MeasurandItems.Add("DP"); . . private void initGrid(string tableName) { this.Cursor = Cursors.WaitCursor; this.gridDataBoundGrid1.BeginUpdate(); this.gridDataBoundGrid1.DefaultColWidth = 100; if(this.theFilterBar != null && theFilterBar.Wired) { theFilterBar.RowFilter = ""; //reset the old table theFilterBar.UnwireGrid(); //Filter ausschalten } this.gridDataBoundGrid1.DataSource = this.dataSet1.Tables[tableName]; //Column "Type" initialize default with Comboboxes GridBoundColumnsCollection gbcc = this.gridDataBoundGrid1.Binder.InternalColumns; gbcc["Type"].StyleInfo.CellType = "ComboBox"; theFilterBar = new GridFilterBar(); theFilterBar.WireGrid(this.gridDataBoundGrid1); this.gridDataBoundGrid1.EndUpdate(); this.Cursor = Cursors.Arrow; } // ############################################# . . private void gridDataBoundGrid1_CellClick(object sender, Syncfusion.Windows.Forms.Grid.GridCellClickEventArgs e) { GridBoundColumnsCollection gbcc = this.gridDataBoundGrid1.Binder.InternalColumns; if (gridDataBoundGrid1[gridDataBoundGrid1.CurrentCell.RowIndex, 2].Text == "command") { gbcc["type"].StyleInfo.CellType = "ComboBox"; gbcc["type"].StyleInfo.DataSource = this.CommandItems; } if (gridDataBoundGrid1[gridDataBoundGrid1.CurrentCell.RowIndex, 2].Text == "measurand") { gbcc["type"].StyleInfo.CellType = "ComboBox"; gbcc["type"].StyleInfo.DataSource = this.MeasurandItems; } } Thanks Markus

Administrator [Syncfusion]
Replied On February 6, 2003 01:34 PM UTC

With respect to your code snippets, you have both "Type" and "type". These mappingnames are case sensitive. So, changing that might get your code running. Instead of using the CellClick event, you might want to try the CurrentCellValidated event, and if it is your 'master' that has been changed, go ahead and set the datasource for the slave column. If you really want to do it at the point of dropdown, then try catching the CurrentCellShowingDropdown event, and in that event set the ListBox that is used in the dropdown.
private void gridDataBoundGrid1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e)
	GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;

	//create or get the table somehow
	table = new DataTable();


	//make dropdown list use this new table....
	ListBox listBox = ((GridComboBoxCellRenderer)cc.Renderer).ListBoxPart;
	listBox.DataSource = null;
	listBox.DisplayMember = "Item";
	listBox.ValueMember = "ItemID";
	listBox.DataSource = restrictedForeignTable;
	listBox.BindingContext = this.BindingContext;

Markus Kraft
Replied On February 7, 2003 04:20 AM UTC

Thanks it works.... The mappingnames "Type" and "type" in the code snippets is a translation error from german to english (sorry).


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon