transfer data from datagrid to new form

alaric

Well-known member
Joined
Oct 12, 2005
Messages
53
Programming Experience
Beginner
Hi
I'm just starting my first app and run into following problem I cant get fixed.

I have a form with a datagrid( user can only delete records here). When user wants to edit a record he doubliclicks a row and a new form shopul open with all the containing row data from the data grid. The data is of mixed type; text, numbers, nulls, numbers who I want to be displayed as checkbox;

this is what I tried. (frmadresboek_ed = form2)
VB.NET:
[SIZE=2][COLOR=#0000ff]
Dim[/COLOR][/SIZE][SIZE=2] frmadresboek_ed [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] frmAdresboek_ed
frmadresboek_ed.txtCursistId.Text = [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Datagrid1.Item([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Datagrid1.CurrentRowIndex, 0)
frmadresboek_ed.txtVoornaam.Text = [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Datagrid1.Item([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Datagrid1.CurrentRowIndex, 1)
frmadresboek_ed.txtAchternaam.Text = [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Datagrid1.Item([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Datagrid1.CurrentRowIndex, 2)[/SIZE]
frmadresboek_ed.show()

it cant convert (ofcourse) the nulls to string.

2 Questions:
Is this the best way to do this or are there better ways (I think there are, but cant think of a solution as a newbee)

how to solve this, one way or another? please help
 
I would not try to transfer all the row data but just the key. By doing this you can use a bindingManager in the other form where you just need to set the position to the value of the key or rowindex you wanted to edit on the datagrid and the bindingmanager will fetch everything itself. ofcourse it's required to databind all the controls on the edit form.

Google for BindingManagerBase class
 
use bindingmanager

HI suddenelfilo,

I did google around and read various articles, but don't understand how to use it. Im new to vb.net, so I'm looking for an example on how to implement it in my app.
Hope you can help me (or anyone els ofcourse)

thanks.
 
Back
Top