ComboBox .DataSource be dependent on spezific row value
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
SIGN IN To post a reply.
2 Replies
AD
Administrator
Syncfusion Team
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;
}
MK
Markus Kraft
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).
SIGN IN To post a reply.
- 2 Replies
- 2 Participants
-
MK Markus Kraft
- Feb 6, 2003 10:32 AM UTC
- Feb 7, 2003 04:20 AM UTC