Victor Charles
asked on
Help with selecting rows in Grid based on string value
Hi,
I tried the code below to select rows 2 and 3 (utubeC = "1,2") but getting error message: Not supported when the Grid is bound
on line:
If utubeC.Split(",").Contains (C1SDeacti vation.Row s(i).ToStr ing) Then
utubeC = "1,2"
C1SDeactivation.ClearField s()
For i As Integer = 0 To C1SDeactivation.RowCount - 1
If utubeC.Split(",").Contains (C1SDeacti vation.Row s(i).ToStr ing) Then
C1SDeactivation.SelectedRo ws.Add(i)
End If
Next
How do I fix this error?
I am using a TrueDBGrid from componentOne, but hoping solution for GridView will also solve this issue.
Victor
I tried the code below to select rows 2 and 3 (utubeC = "1,2") but getting error message: Not supported when the Grid is bound
on line:
If utubeC.Split(",").Contains
utubeC = "1,2"
C1SDeactivation.ClearField
For i As Integer = 0 To C1SDeactivation.RowCount - 1
If utubeC.Split(",").Contains
C1SDeactivation.SelectedRo
End If
Next
How do I fix this error?
I am using a TrueDBGrid from componentOne, but hoping solution for GridView will also solve this issue.
Victor
ASKER
Hi,
Thanks for the code, when I tried it, I received error messsage: "CellIndex is not declared it may be inaccessible due toi its protection level.
Thanks for the code, when I tried it, I received error messsage: "CellIndex is not declared it may be inaccessible due toi its protection level.
When I use undeclared variables in my code examples, I expect you to replace those appropriately. What CellIndex meant is... index of the column that you are trying to check (such as ID) just like you are using i as rowindex.
ASKER
I am checking the string variable against the first column in the Grid.
SDeactivation_ID SDeactivation
0 ItemA
1 ItemB
2 ItemC
3 ItemD
Tried the following code:
If utubeC.Split(",").Contains (C1SDeacti vation.Row s(i).Cells (SDeactiva tion_ID).V alue.ToStr ing) Then
But it still does not work. Error SDeactivation is not declared,it may be inaceesible to to its protection level.
Also tried:
If utubeC.Split(",").Contains (C1SDeacti vation.Row s(i).Cells ("SDeactiv ation_ID") .Value.ToS tring) Then
SDeactivation_ID SDeactivation
0 ItemA
1 ItemB
2 ItemC
3 ItemD
Tried the following code:
If utubeC.Split(",").Contains
But it still does not work. Error SDeactivation is not declared,it may be inaceesible to to its protection level.
Also tried:
If utubeC.Split(",").Contains
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That also did not work, waiting to hear back from componentOne.
Thanks,
Victor
Thanks,
Victor
ASKER
I'm not getting an error with code below but i is stuck in 0, any ideas why?
I tried i = i + 1 within the loop but msgbox value only shows 0, which i assume is the value for the first row.
For i As Integer = 0 To C1SDeactivation.RowCount - 1
MsgBox(C1SDeactivation.Col umns(0).Va lue.ToStri ng)
If utubeC.Split(",").Contains (C1SDeacti vation.Col umns(0).Va lue.ToStri ng)
Then
C1SDeactivation.SelectedRo ws.Add(i)
End If
Next
I tried i = i + 1 within the loop but msgbox value only shows 0, which i assume is the value for the first row.
For i As Integer = 0 To C1SDeactivation.RowCount - 1
MsgBox(C1SDeactivation.Col
If utubeC.Split(",").Contains
Then
C1SDeactivation.SelectedRo
End If
Next
You are only using .Columns collection without any reference to a row hence same value all the time.
Should that not be
If utubeC.Split(",").Contains