Question

I am using Infragistics 2013 version. I have a requirement wherein I have to add a button along with a text in a column in winforms ultragrid. The button will open a pop up screen which allows user to select a value that will be displayed as a text in the grid's column.

Thank you.

Was it helpful?

Solution 3

Ok got the answer.

Had to set the columns style to EditButton.

UltraGrid1.DisplayLayout.Bands(0).Columns("ColName").Style = Infragistics.Win.UltraWinGrid.ColumnStyle.EditButton

OTHER TIPS

Set the Style of the Column to ColumnStyle.EditButton. For example:

UltraGrid1.DisplayLayout.Bands(0).Columns("ColName").Style = Infragistics.Win.UltraWinGrid.ColumnStyle.EditButton 

You can then handle the UltraGrids CellButtonClicked event to know when the button was clicked where e.Cell will let you know what cell was clicked:

Private Sub UltraGrid1_ClickCellButton(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.CellEventArgs) Handles ultraGrid1.ClickCellButton
   Debug.WriteLine("Button in " & e.Cell.Value.ToString() & " cell was clicked.")
End Sub

Just to extend the answer slightly: If you want the button to be visible all the time (rather than just when you click into the cell containing the button) you may also need to set the ButtonDisplayStyle:

UltraGrid1.DisplayLayout.Bands(0).Columns("ColName").ButtonDisplayStyle = UltraWinGrid.ButtonDisplayStyle.Always

Also, if you want more control over the button's appearance or location then this info from Mike Saltzman from Infragistics may be useful:

If you want buttons that are left-aligned, more than one button in the same cell, or buttons that don't fill the entire cell but contain text and/or images, you can use an editor. The basic approach is something like this:

1) Add an editor control to your form (like UltraTextEditor, for example).

2) Use the ButtonsLeft and/or ButtonsRight collection to add the buttons you want. You can set the Text and Appearance of each button.

3) In code, set the EditorControl of the Column (or Cell) to the editor control. This is essentially like setting the Style but in a more robust way.

4) To handle the click events of the button(s), you handle the events on the editor - not the grid. For example, if it's just a normal button, you would use EditorButtonClick. The event args will pass you a Context which will return the grid cell in which the button was clicked.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top