irritatiing datagrid bug

G

Guest

using VS 2003
create a winforms app
add a datagrid to the form
and bind it to a an arraylist or similar
in the click event of the datagrid pop up a message box
run the app
click on the separator between rows (when you have the double headed
vertical arrow cursor)
the message box pops up but the mouse is trapped within the grid borders!

code below:-

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim a As New ArrayList
a.Add(1)
a.Add(2)
a.Add(3)
Me.DataGrid1.DataSource = a
End Sub


Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DataGrid1.Click
MsgBox("oops", MsgBoxStyle.OKOnly)
End Sub
 
K

Kejpa

But you make a click within the Datagrid, don't you?
Not in the grid area but still within the data grid. You might do a hittest
to see if your in any cell and act upon the result of that.

HTH
/Kejpa
 
S

scorpion53061

Try this and see if your bug replicates

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Debug.WriteLine(Me.ComboBox1.Text & " " & Me.ComboBox1.SelectedValue)
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim arrPerson As New ArrayList()

arrPerson.Add(New Person("1", "11"))
arrPerson.Add(New Person("2", "22"))
arrPerson.Add(New Person("3", "33"))
arrPerson.Add(New Person("4", "44"))

Me.ComboBox1.DataSource = arrPerson
Me.ComboBox1.DisplayMember = "Name"
Me.ComboBox1.ValueMember = "ID"

Me.DataGrid1.DataSource = arrPerson
End Sub

Public Class Person

Private _Name As String
Private _ID As String

Public Sub New(ByVal strName As String, ByVal strID As String)
MyBase.New()
Me._Name = strName
Me._ID = strID
End Sub

Public ReadOnly Property Name() As String
Get
Return _Name
End Get
End Property

Public ReadOnly Property ID() As String
Get
Return _ID
End Get
End Property

End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top