PC Review


Reply
Thread Tools Rate Thread

Datagrid.VisibleColumnCount on a tabControl failing.

 
 
Steve Goodman
Guest
Posts: n/a
 
      5th Sep 2003
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.



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tablestyle failing w/ custom datagrid =?Utf-8?B?S21pc3RpYw==?= Microsoft VB .NET 0 29th Nov 2005 09:29 PM
TabControl how do get close tab [x] on tabcontrol ? MumboJumbo Microsoft C# .NET 3 22nd Apr 2005 02:25 PM
Deleting row from datagrid failing =?Utf-8?B?a3NlZHJhbg==?= Microsoft VB .NET 2 18th Nov 2004 10:39 PM
Tabcontrol with datagrid Earl Microsoft Dot NET Compact Framework 0 28th Aug 2004 04:52 PM
Datagrid Update Failing - Read only? Learning SQL Server Microsoft ADO .NET 3 7th Aug 2003 06:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:42 AM.