datagrid problem

ronin2307

Member
Joined
Mar 10, 2005
Messages
16
Programming Experience
1-3
somehow my datagrid is doubling up on the scrollbars and I don't know why.

any help will be greatly appreciated
 

Attachments

  • debug.gif
    debug.gif
    3.6 KB · Views: 198
code

Global
visual basic code:
Dim tMain As New Thread(New ThreadStart(AddressOf MainProc))​
Button Code
visual basic code: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

'clear screen
DsLogColl.Tables(0).Rows.Clear()
StatusBar1.Text = ""

DataGrid1.Refresh()

If Not ImportData() Then
Exit Sub
End If

'set up the progress bar
ProgressBar1.Value = 0
ProgressBar1.Maximum = DSImport.Tables(0).Rows.Count

'start MainProc()
tMain.Start()

End Sub​
MainProc()
visual basic code:Private Sub MainProc()
'before stuff

'when found
Dim dr As DataRow = DsLogColl.Tables(0).NewRow
dr(0) = LTrim(RTrim(CType(INVScreen.m2mpageframe1.page2.txtfpartno.Value, String)))
dr(1) = INVScreen.m2mpageframe1.page2.txtfmatlcost.Value
dr(2) = DSImport.Tables(0).Rows(intSearchCount).Item(1)
DsLogColl.Tables(0).Rows.Add(dr)
dr = Nothing
Datagrid1.Refresh()

'after stuff
End Sub
 
Have you put your DataGrid on a Panel or some other container control, which would display its own scrollbars?

Also, you may not be aware because VS.NET 2003 let's you get away with it but you are not supposed to access controls created on one thread directly from another thread. You should be using delegates to marshall your method calls to the thread on which the controls were created. If and when you upgrade to VS 2005 it will enforce this. If you don't do it of your own accord now then you may get unexpected errors that are hard to debug. I suggest you check the help topic for the Control.Invoke method for more information.
 
tried in 2005

I have found out about cross-threading the hard way. I also have a beta of 2005 and it happend as you mentioned, I was warned about the issues when I tried to run my app. So I did "fix" the code. I does use callback functions between the datagrid refresh and the thread which populates the dataset that is bound to the datagrid.
still no success, it does the same thing.
 
Back
Top