Hi,
For a cell, I''ve assigned a ComboBox to its celltype. I want to get its onclick event, but it should not be combo button custom control.
Please advice me, how should I do it.
Thanks & Regards,
Sathish.
AD
Administrator
Syncfusion Team
July 3, 2006 04:51 PM UTC
Hi Sathish,
For click on a textbox part of the combo box cell:
You can use the GridComboBoxCellRenderer.TextBox''s click event to catch the single click on the text part of the comobox cell in a grid. Here is a code snippet.
//Form Load
GridComboBoxCellRenderer cr = this.gridControl1.CellRenderers["ComboBox"] as GridComboBoxCellRenderer;
cr.TextBox.Click +=new EventHandler(TextBox_Click);
private void TextBox_Click(object sender, EventArgs e)
{
Console.WriteLine("clicked");
}
For click on the dropdown button of the combo box cell:
To catch the single click event of the combo box cell dropdown button in a grid , you need to handle the grid''s CellButtonClicked .Here is a code snippet.
//Form Load.
this.gridControl1.CellButtonClicked += new Syncfusion.Windows.Forms.Grid.GridCellButtonClickedEventHandler(this.gridControl1_CellButtonClicked);
private void gridControl1_CellButtonClicked(object sender, Syncfusion.Windows.Forms.Grid.GridCellButtonClickedEventArgs e)
{
if( e.Button is Syncfusion.Windows.Forms.Grid.GridCellComboBoxButton )
Console.WriteLine("Welcome" + e.Button );
}
Let me know if this helps.
Best Regards,
Haneef
CH
Clive Hill
July 6, 2006 12:08 PM UTC
Did this work?
If I set up the following:
GGC.TableControlCurrentCellShowingDropDown += new Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCurrentCellShowingDropDownEventHandler(GGC_TableControlCurrentCellShowingDropDown);
and then have this:
private void GGC_TableControlCurrentCellShowingDropDown(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCurrentCellShowingDropDownEventArgs e)
{
//Use this method to popualte the drop down
GridCurrentCell cc = e.TableControl.CurrentCell;
GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer;
if( cr != null)
{
cr.TextBox.Click +=new EventHandler(TextBox_Click);
}
}
When I click on an item in the drop down TextBox_Click method is not trigerred.
CH
Clive Hill
July 6, 2006 01:03 PM UTC
If I do:
cr.ListBoxPart.Click +=new EventHandler(ListBoxPart_Click);
Instead the event is captured.
Unfortunately, there doesn''t seem to be a way to get reference to the cell this event originated from to update the displayed text.
CH
Clive Hill
July 6, 2006 04:32 PM UTC
Actually, GGC.TableControl.Table.CurrentRecord.GetValue can be used. I now update the value from ListBoxPart_Click using the QueryCellStyleInfo.
If I change the selected item in drop down the display text isn''t updated (it is set correctly using e.Style.Text though) until the user clicks on anything else other than that cell.
Is there a way to get the text to refresh immediately?
AD
Administrator
Syncfusion Team
July 6, 2006 07:32 PM UTC
Hi Vito,
Here is a code snippet which demonstrates a way to update the grid cell, when the user selected a value in the dropdown. Updating the selected value in the QueryCellStyleInfo event would cause a performance issue. I hope this code helps to solve your issue, kindly update us more details if your requirement is different.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
private void gridGroupingControl1_TableControlCurrentCellCloseDropDown(object sender, GridTableControlPopupClosedEventArgs e)
{
GridCurrentCell cc = this.gridGroupingControl1.TableControl.CurrentCell;
GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer;
Record r = this.gridGroupingControl1.Table.CurrentRecord;
if(r!=null)
{
object value = cr.ListBoxPart.SelectedValue;
if(value != null)
{
r.SetValue("Col0",value);
this.gridGroupingControl1.TableControl.RefreshRange(GridRangeInfo.Row(cc.RowIndex));
}
}
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Best regards,
Madhan