IF condition in Datagridview

Asked

Viewed 85 times

0

Hello.

How can I perform a check of the first number of a grid Row ?

Example:

 If Conversions.ToString(Me.DataGridView1.CurrentRow.Cells(0).Value)[0(primeiro número da row)] == (for igual a:) 5  Then 
 WebBrowser1.Document.GetElementById("ibMaster").InvokeMember("click")
If Conversions.ToString(Me.DataGridView1.CurrentRow.Cells(0).Value)[0(primeiro número da row)] == (for igual a:) 4  Then
 WebBrowser1.Document.GetElementById("ibFitness").InvokeMember("click")
  • I don’t understand your question... what you consider the "first number of a grid Row"? Can further develop your question?

  • It would be the first number in the first column of the datagrid, following print: http://prntscr.com/khdr5g

  • Then, like, the program would check: Se (o primeiro número da coluna for) == 1 Then Variável a (string) = "ibMestre" End

2 answers

0

You can put it in the eveneto click of the button:

For Each dg As DataGridViewRow In DGV_LANCAMENTO.Rows
    If dg.Cells(0).Value.ToString() = " valor em causa" Then
    End I
Next

0


It was almost there in the code you put in your question!

If Convert.ToString(Me.DataGridView1.CurrentRow.Cells(0).Value)(0) = "5" Then
    WebBrowser1.Document.GetElementById("ibMaster").InvokeMember("click")
ElseIf Convert.ToString(Me.DataGridView1.CurrentRow.Cells(0).Value)(0) = "4" Then
    WebBrowser1.Document.GetElementById("ibFitness").InvokeMember("click")
End If
  • Thank you very much!

  • How can I check the first six digits ? Example: ElseIf Convert.ToString(Me.DataGridView1.CurrentRow.Cells(0).Value)(0 até 6) = "530032" Then ...

  • I think it is enough to put "Substring(0, 6)".

  • This error appears: "Substring is not declared" ElseIf Convert.ToString(Me.DataGridView1.CurrentRow.Cells(0).Value)(SubString(0, 6)) ... I got it this way: ElseIf Convert.ToString(Me.DataGridView1.CurrentRow.Cells(0).Value).SubString(0, 6)

  • Exactly, and that’s how I had to use the Substring() :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.