Prof_MAM
asked on
datagrid cell selection
I have datagrid contian 3 fields from database table and 3 textbox ,what I want is a code to make the the 3 textbox show the datagrid field depending on selected row from datagrid . when clicking on any cell of the dtagrid the 3 textbox should show content of that row.
Just bind the textboxes to the same datasource as the datagrid, then there is no extra coding needed, it will navigate automatically
ASKER
how to bind datagrid and the text box to datasource
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 is good , it works corrctly But what If I have String varialble ? Can I bind it also ? Itryed this code but it didn't work
Str_Var.DataBindings.Add(" Text", GridDataSet.Tables(0), "Std_ID") .
Str_Var.DataBindings.Add("
What is the error you are getting (because the type doesn't matter)
ASKER
str_var.databindings is underlined by blue
Than it doesn't understand str_var , what should str_var be ? The name of your textbox ?
ASKER
no no, it is a string variable.
Well you can't add databindings to any variable. Databinding is used for controls like a textbox or datagrid etc..
you said you wanted to
"what I want is a code to make the the 3 textbox show the datagrid field depending on selected row from datagrid "
so where does this variable fit in
you said you wanted to
"what I want is a code to make the the 3 textbox show the datagrid field depending on selected row from datagrid "
so where does this variable fit in
ASKER
Sorry but I changed one of The 3 textbox by A string Variable .
So there is no solution ?
So there is no solution ?
Yes there always is a solution, but what are you trying to achieve exactly.
ASKER
Ok that will be In anothor Question .
ASKER
this is anothor question
https://www.experts-exchange.com/questions/21208533/A-string-variable-and-datagrid-question.html
https://www.experts-exchange.com/questions/21208533/A-string-variable-and-datagrid-question.html
Dim r As Integer
r = datagrid.CurrentCell.RowNu
textbox1.text= datagrid.Item(r, 0) '0 for first column
textbox2.text= datagrid.Item(r,1) '1 for second column
textbox3.text= datagrid.Item(r, 2) '0 for third column
End Sub
if you require more information just write