Home Forums WinForms controls Xceed Grid for WinForms cell button Reply To: cell button

Xceed Support
Post count: 5658

Here is some sample code that should meet your requirement:

Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim col1 As New Column(“Column1”)
Dim col2 As New Column(“Column2”)
For i As Integer = 0 To 9

Dim row As Xceed.Grid.DataRow = gridControl1.DataRows.AddNew()
For Each cell As Cell In row.Cells
cell.Value = “Test”
row.Height = row.Height * 2

Dim wtb As New WinTextBox(EnhancedBorderStyle.None)
Dim but As New Button()
but.Text = “My button”
but.BackColor = Color.LightGray
col1.CellEditorManager = New TextEditor(wtb)
AddHandler col1.CellEditorManager.ActivatingControl, AddressOf CellEditorManager_ActivatingControl
col1.CellViewerManager = New TextViewer(wtb)
End Sub

Private Sub CellEditorManager_ActivatingControl(ByVal sender As Object, ByVal e As CellEditorEventArgs)
AddHandler DirectCast(DirectCast(e.Control, WinTextBox).Controls(1), Button).Click, AddressOf Form1_Click
End Sub

Private Sub Form1_Click(ByVal sender As Object, ByVal e As EventArgs)
MessageBox.Show(“Hello World”)
End Sub

Imported from legacy forums. Posted by CharlesB (had 365 views)