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

Xceed Support
Member
Post count: 5658

Here is some sample code that should meet your requirement:

<code>
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim col1 As New Column(“Column1”)
Dim col2 As New Column(“Column2”)
gridControl1.Columns.Add(col1)
gridControl1.Columns.Add(col2)
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”
Next
row.EndEdit()
row.Height = row.Height * 2
Next

Dim wtb As New WinTextBox(EnhancedBorderStyle.None)
Dim but As New Button()
but.Text = “My button”
but.BackColor = Color.LightGray
wtb.Controls.Add(but)
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
</code>

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