DataGrid text box column

  • Thread starter Thread starter neil rowe
  • Start date Start date
N

neil rowe

Hi all

How do I trap the click event of a standard datagrid text box column on a
windows form ?

Regards

Neil
 
Hi,

You need to add a tablestyle to the grid. Add a handler to the
columns textbox click event.

Private Sub SetupGrid()

Dim ts As New DataGridTableStyle

ts.MappingName = dsInvoicesData.Tables(0).TableName



Dim colDescription As New DataGridTextBoxColumn

With colDescription

..MappingName = "Description"

..HeaderText = "Description"

..Width = 280

..NullText = ""

End With

AddHandler colDescription.TextBox.Click, AddressOf Me.HandlesDataColumnClick

Dim colQty As New DataGridTextBoxColumn

With colQty

..MappingName = "Quantity"

..HeaderText = "Qty"

..Width = 50

End With

Dim pd As System.ComponentModel.PropertyDescriptor =
cm.GetItemProperties()("Each")



Dim colEach As New DataGridTextBoxColumn(pd, "C")

With colEach

..MappingName = "Each"

..HeaderText = "Each"

..Width = 50

End With

Dim colPrice As New DataGridTextBoxColumn(pd, "C")

With colPrice

..MappingName = "Price"

..HeaderText = "Price"

..Width = 50

End With

ts.GridColumnStyles.Add(colDescription)

ts.GridColumnStyles.Add(colQty)

ts.GridColumnStyles.Add(colEach)

ts.GridColumnStyles.Add(colPrice)

dgInvoiceData.TableStyles.Add(ts)

ts = Nothing

colPrice = Nothing

colEach = Nothing

colQty = Nothing

colDescription = Nothing

End Sub

Private Sub HandlesDataColumnClick(ByVal sender As Object, ByVal e As
System.EventArgs)

MessageBox.Show("Click")

End Sub


Ken
 
Back
Top