Datagridview - change in cell affects entire row?

IneedaSmoke

Active member
Joined
Mar 4, 2008
Messages
26
Programming Experience
Beginner
Hey all, still having some trouble with a dgv. I have multiple columns with some being user input and others as output only from other calculations.

VB.NET:
    Private Sub doSomething()

        incrementNumber()
        dt.Rows(0).Item(0) = testNumber
        dt.Rows(0).Item(1) = testNumber * 2
    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        Dim t As Thread
        t = New Thread(AddressOf doSomething)
        t.Start()



        If testNumber = 10 Then
            'MsgBox("pause")
            Me.DataGridView1.Rows(0).Cells(0).Style.BackColor = Color.Red
        End If
    End Sub

I've created a timer where one cell increments on each tick. Unfortunately, when it updates that datatable cell it resets any field in the same row that someone might be adding data.

I was hoping that multithreading this it might take the focus away but i'm guessing :

VB.NET:
dt.Rows(0).Item(0) = testNumber
        dt.Rows(0).Item(1) = testNumber * 2

are row calls. Basically, if i try to have a user put in anything in item 3+, if the user is 'in the process' of adding something, it resets when these two lines are called.


Any suggestions?

TIA
 
VB.NET:
DataGridView1.Rows(0).Cells(0).Value = testNumber

That works like a charm. I've got this binded to the datatable 'dt'. I guess the lesson is to use the grid or use the dt but not both.
 
Back
Top