Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a datagrid that I use to get data from a table and a multiline textbox, tbdefine, that is used to display one of the columns from this table that I wanted to show separate from the grid. I bound the textbox to the dataview, dv, as follows:

 

Me.tbDefine.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.dv, "definition"))

 

The definition column shows up in tbDefine when my grid first loads and the first row is highlighted, but when I click on another row in the datagrid the text in the textbox doesn't change.

 

What am I missing?

 

Thanks for your help.

  • 3 weeks later...
Posted

Hi,

 

Your binding code is fine, but you need to change the Position property of the associated binding manager to have the textbox change. Even if you have also associated the grid with the table, the grid will simply show the whole table, but will not care about the Position property.

 

To summarize, you need to detect that the user moved to a new row in the grid and set the Position property of the binding manager.

 

Note that you will get the binding manager through:

 

Dim bmb as BindingManagerBase = Me.tbDefine.BindingContext.Item(Me.dv)

 

(I'm a C# guy, so the VB.NET may be incorrect. The C# equivalent is: BindingManagerBase bmb = tbDefine.BindingContext[dv] )

 

And yes, it will be easier in .NET 2; I just read: http://www.fawcette.com/vsm/2004_01/magazine/features/dollard/default_pf.aspx

 

HTH,

jmp

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...