Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to determine the field a textbox is bound to
Message
From
29/10/2010 10:15:55
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 8.0
OS:
Vista
Network:
Windows XP
Database:
Jet/Access Engine
Application:
Desktop
Miscellaneous
Thread ID:
01487443
Message ID:
01487493
Views:
55
Marc,

I'm not 100% sure exactly what you're trying to get at, but I'll give it a shot. What I'm not clear about in your post is what "cols" is. Here's a snippet of code that I have used in my TextBox sub-class (sorry, it's C#, so I hope you can follow it):
// oBinding is simply what the TextBox is bound to
// Me.DataBindings.Item(0) in your example

int nRow = this.BindingContext[this.oBinding.DataSource].Position;
string field = this.oBinding.BindingMemberInfo.BindingField;

DataTable table = null;
if (this.oBinding.DataSource is DataView)
{
	nRow = CommonFunctions.IndexOfRow((DataView)this.oBinding.DataSource, nRow);
	table = ((DataView)this.oBinding.DataSource).Table;
}
else
	if (this.oBinding.DataSource is DataTable)
		table = (DataTable)this.oBinding.DataSource;
It appears that you're also talking about a sub-classed control, I hope I am correct in that assumption. Since your question appears to be about whatever this "cols" thing is, I'm not sure if the above helps or not.

If not, perhaps you can rephrase your question or post some more code.

~~Bonnie


>I have found that
>
>Me.DataBindings.Item(0).BindingMemberInfo.BindingField
>
>
>gives me the name of the field a control is bound to.
>
>
>Dim o As DataColumn = cols(Me.DataBindings.Item(0).BindingMemberInfo.BindingField)
>
>
>gets me the column, or the field that I am looking for.
>
>cols is passed to the method from the form's dataset.datatable (I guess).
>
>Is there a way for a textbox to let it's findform produce these (dataset.datatable).cols?
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform