I am having trouble getting the datagrid.VisibleColumnCount property to
return the correct value for datagrids that are on separate tabpages of a
tabbed dialog.
The first datagrid returns the correct value, yet the subsequent two other
datagrids only return back 0. However if I place a break point on the line,
place the mouse over the property it still returns 0, then if I expand the
datagrid in the watch window and scroll down to the property it has the
correct value in, if I then put the mouse back over the property it appears
correctly. The bug is not down to a timing issue as if I wait for a minute
or two the value still does not appear in the property, it only seems to get
the right value when I expand and close the datagrid in the watch window.
I have managed to get this to fail with even the most basic of code, is this
a bug with .Net, or am I doing something really wrong?
'-----------------------------------------------------------------------CODE
-------------------------------------------------------------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
populateGrid(dgEmployees, "select * from Employees")
populateGrid(dgorders, "Select * from orders")
populateGrid(dgCustomers, "Select * from customers")
End Sub
Private Sub populateGrid(ByVal dg As DataGrid, ByVal sSQL As String)
Dim cnn As OleDbConnection
Dim da As OleDbDataAdapter = New OleDbDataAdapter
Dim dt As DataTable = New DataTable
cnn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Program Files\Microsoft Visual Studio\VB98\NWIND.MDB;User
Id=admin;Password=;")
cnn.Open()
da.SelectCommand = New OleDbCommand(sSQL, cnn)
da.Fill(dt)
dg.DataSource = dt
MsgBox(dg.VisibleColumnCount.ToString)
End Sub
Thanks for any help.
Steve.
|