By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,988 Members | 1,049 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,988 IT Pros & Developers. It's quick & easy.

Fill Text box from datagridview selected item

P: 122
I have a unique situation I have two datagrids each has its datasource set to a list of objects.

i.e grid1.DataSource = List<Companies>
grid2.DataSource = List<Divisions>

Basically what i want to do is eventually link the two data grids so that when you click on the companies datagrid it lists all the divisions (companies) for the main company.

That part I think I can handle, below it on the same form i have all the text boxes etc. that will display all the values on the selected item (from either grid)

This is the part I don't know how to do and can't seem to find any code on how to make it happen.

So could someone show me how i can make that textbox display the information in say cell 2 of the selected item.

Jan 22 '09 #1
Share this Question
Share on Google+
2 Replies

P: 39
I don't know if this is exactly what you want, but how I interpreted it you wanted to get the text in Cell 2 of the selected row?
Expand|Select|Wrap|Line Numbers
  1. if(grid1.SelectedRows.Count > 0)
  2.      textBox1.Text = grid1.SelectedRows[0].Cell[1].Value.ToString();
Jan 23 '09 #2

P: 122
Yes that works for what I need thanks so much.
Jan 26 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.