Show data in from DataSet in TextBox

  • Thread starter Thread starter PawelR
  • Start date Start date
P

PawelR

Hello Group,
Sorry my english is very little.
I have problem with show data from Table from DataSet in textBox.
In my apps I have "typed DataSet" myDS with table TabPerson [idPerson,
LastName, FirstName, Adres, telefon]
On Form I have dataGrid with one column form TabPerson - with LastName and 3
textBoxes tbFName, tbAdres, tbTel.
Event DoubleClick for dataGrid is
tbAdres.Text = myDS.TabPerson[dataGrid.CurrentRowIndex].Adres;

If I don't sort column this work correct - because index in dataGrid is the
same as index in TabPerson.
My question is how get correct index from dataGrid to show data in textBox
if I sort columns?

Thx
PawelR
 
Hi Pawel,

Use DataView to show your data in the DataGrid.
Its most universal way to access data by index or
state.
You can try to access: DataTable.DefaultView to get
current index, but i don't test it.

HTH
Marcin
 
Pawel,

In a not strongly format it can be

\\\
dataGrid1.DataSource = ds.Tables[0].DefaultView;
textBox1.DataBindings.Add(new Binding("Text", ds.Tables[0].DefaultView,
"Pawel"));
////

I hope this helps?

Cor
 
Pawel,

Strongly typed it can be
\\\
dataGrid1.DataSource = ds.Pawel.DefaultView;
textBox1.DataBindings.Add(new Binding("Text",
ds.Pawel.DefaultView, "Pawel"));
///

I hope this helps?

Cor
 
Thanks,
this very good way.
Now, when my apps growing up I have new problem. I add to my Form new
dataGrid and I want show in this component data from child table, but I
don't know how binding this table. I have dataRelation object but this not
work. The same relation, I have in dataBase.

Thx PAwel
 
Back
Top