Home All Groups Group Topic Archive Search About

Getting content from one column in a datagrid in a textbox

Author
4 Sep 2006 4:10 PM
reidarT
I have a datagrid with columns. One of the columns are a textbox.
I want the text in this column shown in a textbox outside the datagrid.
How can I do that when clicking the actual row in the datagrid?
reidarT

Author
4 Sep 2006 7:29 PM
Mike McIntyre
For .NET 1.x or 2.0?

--
Mike

Mike McIntyre [MVP]
http://www.getdotnetcode.com


Show quoteHide quote
"reidarT" <rei***@eivon.no> wrote in message
news:Olo%23nyD0GHA.996@TK2MSFTNGP03.phx.gbl...
>I have a datagrid with columns. One of the columns are a textbox.
> I want the text in this column shown in a textbox outside the datagrid.
> How can I do that when clicking the actual row in the datagrid?
> reidarT
>
Author
4 Sep 2006 7:54 PM
reidarT
for .net 2.0
reidarT
Show quoteHide quote
"Mike McIntyre" <mik***@getdotnetcode.com> skrev i melding
news:%233ze5hF0GHA.4796@TK2MSFTNGP06.phx.gbl...
> For .NET 1.x or 2.0?
>
> --
> Mike
>
> Mike McIntyre [MVP]
> http://www.getdotnetcode.com
>
>
> "reidarT" <rei***@eivon.no> wrote in message
> news:Olo%23nyD0GHA.996@TK2MSFTNGP03.phx.gbl...
>>I have a datagrid with columns. One of the columns are a textbox.
>> I want the text in this column shown in a textbox outside the datagrid.
>> How can I do that when clicking the actual row in the datagrid?
>> reidarT
>>
>
>
Author
4 Sep 2006 9:59 PM
Mike McIntyre
You can bind the Text property of your 'off the grid' TextBox to your
DataGridView's BindingSource text column and the TextBox will display the
text for the row selected in the DataGridView.

..1 At design time you can select the TextBox that is outside the
DataGridView, view its properties, select DataBindings -> Advanced to open
the 'Formatting and Advanced Binding' dialog where you can associate the
column of the BindingSource with the TextBox.

OR

2. For runtime binding you will need to add code similar to this to bind the
TextBox Text property to the BindingSource:
Me.TextBox1.DataBindings.Add(New System.Windows.Forms.Binding("Text",
Me.CustomerBindingSource, "Name", True))

The example above shows the Text property of a TextBox named TextBox1 being
bound to the "Name" column of a BindingSource named CustomerBindingSource.
--
Mike

Mike McIntyre [MVP]
http://www.getdotnetcode.com


Show quoteHide quote
"reidarT" <rei***@eivon.no> wrote in message
news:Olo%23nyD0GHA.996@TK2MSFTNGP03.phx.gbl...
>I have a datagrid with columns. One of the columns are a textbox.
> I want the text in this column shown in a textbox outside the datagrid.
> How can I do that when clicking the actual row in the datagrid?
> reidarT
>