Thijser Thijser - 11 months ago 54
C# Question

How to react to a onlick in an ultragrid

I have code that creates an UltraGrid with a column that has the

as it's style.

private void Grid_InitializeLayout(object sender, InitializeLayoutEventArgs e){

var column = Grid.SetColumn("Draw Lines", "Draw Lines", 30);
column.Style = ColumnStyle.Button;


Now I would like too make it react to being clicked on. I have found this but it does not show me how to bind the variable, usually I can either double click in the visual studio editor (but in this case this only directs me too the
) or I can go the the item in question and add the function to an
variable, but this one doesn't exist.

private void Grid_InitializeRow(object sender, InitializeRowEventArgs e)
var buttoncell= e.Row.Cells["Draw Lines"];
//something here?

this is what I want to call

private void OnDrawLine(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
Debug.Print("test test");

It's probably something trivial but I'm stuck.

Answer Source

The UltraGrid responds to clicks on a cell button as explained in the link posted using an event called ClickCellButton. You need to subscribe to this grid event in the usual ways. (Designer or code doesn't matter)

private void Grid_ClickCellButton(object sender, ClickCellEventArgs e)
    // Check if the click happens on the required column
    if (e.Cell.Column.Key == "Draw Lines")
        ... your code ...