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

Events from a dynamically created combobox

Hi, I am dynamically created adding a column in a databound grid and defining the cell type as follows: ********************************************* GridBoundColumn gbc = new GridBoundColumn(); GridDataBoundGridModel model = m_GridDataBoundGrid.DataBoundGridModel; gbc.MappingName = strField; gbc.HeaderText = strHeaderName; m_GridDataBoundGrid.GridBoundColumns.Add(gbc); GridStyleInfo colStyle = model.ColStyles[strField]; colStyle.CellType = "ComboBox"; ********************************************** Now my question is that, how do I catch events like "SelectedIndexChanged" or "SelectedTextChanged" from this combobox that I am dynamically adding. thanks for your help. -Sachin.

3 Replies

AD Administrator Syncfusion Team May 2, 2003 07:09 PM UTC

You can use standard grid current cell events to catch actions on tne current cell. If you want to catch every change, then you handle CurrentCellChanged. If you want to only catch the action after the user indicates he is finished editing, you can catch CurrentCellValidating or CurrentCellConfirmChanges.


SB Sachin Bammi May 4, 2003 07:35 PM UTC

Thanks for your reply. I am trying the following approach as per your advice. private void m_GridDataBoundGrid_CurrentCellChanged(object sender, System.EventArgs e) { int colindex = m_GridDataBoundGrid.CurrentCell.ColIndex; if(colindex != 2) //To check if it was the type //combobox (i.e. from column 2) return; //The combobox has a choiselist that consists of //the word "BIT". I want to catch the event when //user selects that from the list. So I am trying //the following: if((((Syncfusion.Windows.Forms.Grid.GridDataBoundGrid)sender).CurrentCell).ToString()== "BIT") //This does not work obviously. Is //there a way to know the text chosen //by the user here ? Is there a way to //handle the "SelectedTextChanged"? It //seems that if I use this method as you // had suggested then this event is not //exposed at all. { MessageBox.Show("Yes!"); } } regards, Sachin.


AD Administrator Syncfusion Team May 4, 2003 08:55 PM UTC

You get the new text from the active cellrenderer.
private void grid_CurrentCellValidating(object sender, CancelEventArgs e)

{
	GridCurrentCell cc = this.grid.CurrentCell;

	if(cc.Index == 2)
	{
		string newValue = cc.Renderer.ControlText;
		string oldValue = this.grid[cc.RowIndex, cc.ColIndex].Text;
	}
}

Loader.
Up arrow icon