SandyB Posted January 12, 2004 Posted January 12, 2004 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. Quote
jmpirelli Posted January 27, 2004 Posted January 27, 2004 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 Quote
SandyB Posted January 28, 2004 Author Posted January 28, 2004 Thanks jmp, that helps. And I found that article very interesting. Sandy Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.