Victor Charles
asked on
Help with retreiving value of row when edon it.
Hi,
My grid contains 5 rows. How do I pass the value of the data in the row when I click on it?
The Grid is from componentone.
For example if my Grid contains
A
B
C
D
When I click on the first row, I would like to set s = A, when I click on the second row set s = B etc..
Thanks,
Victor
My grid contains 5 rows. How do I pass the value of the data in the row when I click on it?
The Grid is from componentone.
For example if my Grid contains
A
B
C
D
When I click on the first row, I would like to set s = A, when I click on the second row set s = B etc..
Thanks,
Victor
ASKER
Hi,
I tried the code below, changed [] to () because it was given me an error, but value for s = 0
for each row I select.
s = c1TrueDBGrid1.Columns(c1Tr ueDBGrid1. Col).CellT ext(c1True DBGrid1.Se lectedRows (0))
Thanks,
Victor
I tried the code below, changed [] to () because it was given me an error, but value for s = 0
for each row I select.
s = c1TrueDBGrid1.Columns(c1Tr
Thanks,
Victor
u need to use this code in the click event handler of the grid.
can u try that?
can u try that?
ASKER
Hi,
I receive the text of the first row (i.e. s = A ) regardless which row I select.
Dim s as string
s = c1TrueDBGrid1.Columns(c1Tr ueDBGrid1. Col).CellT ext(c1True DBGrid1.Se lectedRows (0))
Thanks,
Victor
I receive the text of the first row (i.e. s = A ) regardless which row I select.
Dim s as string
s = c1TrueDBGrid1.Columns(c1Tr
Thanks,
Victor
ASKER
Just read your post, will try it and get back to you.
ASKER
I tried the code in the click event but still getting the value of the first row, regardless which row I click on.
ASKER
I tried rowIndex but it still does not work.
s = c1TrueDBGrid1.Columns(c1Tr ueDBGrid1. Col).CellT ext(c1True DBGrid1.Se lectedRows (rowIndex) )
s = c1TrueDBGrid1.Columns(c1Tr
is it the 1st column?
ASKER
Yes, I can't find the current row clicked on. also tried currentIndex but it did not work.
s = c1TrueDBGrid1.Columns(c1Tr ueDBGrid1. Col).CellT ext(c1True DBGrid1.Se lectedRows (CurrentIn dex))
s = c1TrueDBGrid1.Columns(c1Tr
i've added this to the grid handler and got it working every click:
private void c1TrueDBGrid1_Click(object sender, EventArgs e)
{
MessageBox.Show(c1TrueDBGrid1.Columns[c1TrueDBGrid1.Col].CellText(c1TrueDBGrid1.SelectedRows[0]));
}
ASKER
Can you please send me the VB.NET version.
Thanks.
Thanks.
MessageBox.Show(c1TrueDBGrid1.Columns(c1TrueDBGrid1.Col).CellText(c1TrueDBGrid1.SelectedRows(0)))
ASKER
I tried the code below which should be the same with your code but it still does not changethe value of s when I click on dirrent rows.
Private Sub C1NSN_Click(sender As Object, e As System.EventArgs) Handles C1NSN_.Click
Dim s As String
s = C1NSN_.Columns(C1NSN_.Col) .CellText( C1NSN_.Sel ectedRows( 0))
MsgBox(s)
End Sub
Private Sub C1NSN_Click(sender As Object, e As System.EventArgs) Handles C1NSN_.Click
Dim s As String
s = C1NSN_.Columns(C1NSN_.Col)
MsgBox(s)
End Sub
ASKER
Hi, correction.
Private Sub C1NSN_Click(sender As Object, e As System.EventArgs) Handles C1NSN.Click
Dim s As String
s = C1NSN.Columns(C1NSN_.Col). CellText(C 1NSN.Selec tedRows(0) )
MsgBox(s)
End Sub
Private Sub C1NSN_Click(sender As Object, e As System.EventArgs) Handles C1NSN.Click
Dim s As String
s = C1NSN.Columns(C1NSN_.Col).
MsgBox(s)
End Sub
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
It works.
Thank You.
Victor
Thank You.
Victor
ASKER
Hi again,
Not sure what I did wrong, but when click on the grid the code in the click event does not execute, any ideas why the code does not execute?
Not sure what I did wrong, but when click on the grid the code in the click event does not execute, any ideas why the code does not execute?
u posted that it works, did u change anything?
ASKER
I tried using the code in the selchange event since I need to use e.cancel = true, declared s as public, trying to undo my changes, but click event still does not trigger.
try add the event handler from the properties pane in visual studio, the AddHandler might be missing
Open in new window