Hello. Ive added to my ultragrid via code buttons. Each button in one column. Now i want to check when each button is clicked to do a specific action. Now i dont know what sort of method should i write to get individual button clicks. Here is my code of when i add the button and the code that i check for clicks. (The click method triggers with any button click, i want individual click detection)
Dim band As Infragistics.Win.UltraWinGrid.UltraGridBand = bossGrid.DisplayLayout.Bands(0)
band.Columns("BNAME").CellClickAction = CellClickAction.CellSelect band.Columns("FRAPPE").CellClickAction = CellClickAction.CellSelect band.Columns("COFFEE").CellClickAction = CellClickAction.CellSelect For i As Integer = 0 To bossGrid.Rows.Count - 1 bossGrid.Rows(i).Cells("FRAPPEPLUS").Value = _ "+" bossGrid.Rows(i).Cells("COFFEEPLUS").Value = _ "+" Next i For i As Integer = 0 To bossGrid.Rows.Count - 1 bossGrid.Rows(i).Cells("FRAPPEMINUS").Value = _ "-" bossGrid.Rows(i).Cells("COFFEEMINUS").Value = _ "-" Next i bossGrid.DisplayLayout.Bands(0).Columns("FRAPPEPLUS").Style = ColumnStyle.Button bossGrid.DisplayLayout.Bands(0).Columns("FRAPPEMINUS").Style = ColumnStyle.Button bossGrid.DisplayLayout.Bands(0).Columns("COFFEEPLUS").Style = ColumnStyle.Button bossGrid.DisplayLayout.Bands(0).Columns("COFFEEMINUS").Style = ColumnStyle.Button
bossGrid.DisplayLayout.Override.DefaultRowHeight = 20
Private Sub UltraGrid1_InitializeLayout(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.CellEventArgs) Handles bossGrid.ClickCellButton Dim frappePlus As UltraGridColumn = e.Cell.Band.Columns("FRAPPEPLUS")
If e.Cell.Band.Columns("FRAPPEPLUS"). = frappePlus Then (THE PROBLEM IS HERE. I NEED TO DETECT WHICH BUTTON IS PRESSED)
End If
MsgBox("FRAPPEPLUS") End Sub
Any ideas people?
Hi,
The button is not a control, so there's no way to hook an event on the button. You should use the ClickCellButton event of the grid. The event args give you the the cell that was clicked.
is it possible to give me an example?
Antonis,
Are you trying to find which row is the button you have clicked? You can get a reference to the Row from the Cell reference in the ClickCellButton event. I have attached a sample application in which I think you will see what you can do. Look it over and let me know if you have further questions.
yes this is excactly what i need. Thank you very much. If i get into trouble which i hope not ill reply to this post:) thank you again