Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / August 2007

Tip: Looking for answers? Try searching our database.

Dynamic WinForms Label & Textboxes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Patrick - 31 Aug 2007 14:36 GMT
I have a WinForms app, with each forms having many Text-boxes that bind to a
DataTable.

Associate with each Textbox would be a (text) label.  Is there any simple
way such that I can "bind" the Text labels to the TextBoxes, so I can
dynamically set each Label.Text property rather than having to hard-wire the
Label.Text for each Label for textbox?
Alex Meleta - 31 Aug 2007 14:52 GMT
Hi Patrick,

You can create a custom control to combine in it other controls.

Regards, Alex
[TechBlog] http://devkids.blogspot.com

P> I have a WinForms app, with each forms having many Text-boxes that
P> bind to a DataTable.
P>
P> Associate with each Textbox would be a (text) label.  Is there any
P> simple way such that I can "bind" the Text labels to the TextBoxes,
P> so I can dynamically set each Label.Text property rather than having
P> to hard-wire the Label.Text for each Label for textbox?
P>
Patrick - 31 Aug 2007 15:16 GMT
Can you elaborate a little bit more?

I have
1) created a .Net 2TestCustomControl  in VS2005
2) Dragged a Label into the Component designer
3) Dragged a Textbox into the Component designer

What I want is to be able to do something like
MyTestControl.DataBinding.Add("Text",myDataTable["myTable"],"myField");

And for the CustomControls Label.Text and TextBox.DataBindings to be updated
automatically.

What code do I have to write within the Custom Control to achieve this?

> Hi Patrick,
>
[quoted text clipped - 11 lines]
> P> to hard-wire the Label.Text for each Label for textbox?
> P>
Alex Meleta - 31 Aug 2007 16:11 GMT
Hi Patrick,

If you override Text propery of user control (or create another property)
you can put the code to update other controls. Or create two properties for
both databindings.

P> And for the CustomControls Label.Text and TextBox.DataBindings to be
P> updated automatically.
But, do you want to update other bindings by setting only one?

Regards, Alex
[TechBlog] http://devkids.blogspot.com

P> Can you elaborate a little bit more?
P>
P> I have
P> 1) created a .Net 2TestCustomControl  in VS2005
P> 2) Dragged a Label into the Component designer
P> 3) Dragged a Textbox into the Component designer
P> What I want is to be able to do something like
P> MyTestControl.DataBinding.Add("Text",myDataTable["myTable"],"myField"
P> );
P> And for the CustomControls Label.Text and TextBox.DataBindings to be
P> updated automatically.
P>
P> What code do I have to write within the Custom Control to achieve
P> this?
P>
P> "Alex Meleta" wrote:
P>
>> Hi Patrick,
>>
[quoted text clipped - 12 lines]
>> P> to hard-wire the Label.Text for each Label for textbox?
>> P>
Patrick - 31 Aug 2007 17:24 GMT
Where (within the CustomControl) should code to wire up base on the Custom
Property for the Label.Text and TextBox.DataBindings be inserted?

> Hi Patrick,
>
[quoted text clipped - 42 lines]
> >> P> to hard-wire the Label.Text for each Label for textbox?
> >> P>
Alex Meleta - 31 Aug 2007 19:27 GMT
Hi Patrick,

Anywhere add something like.. this (as example):

public void ApplyBinding(DataSet dataSet)
{
 DataBindings.Add("TextBox", dataSet, "Table1.Column1");
 DataBindings.Add("TextLabel", dataSet, "Table1.Column2");
}, where TextBox and TextLabel are properties onto edit box and label.

Certain example depends on real needs.

Regards, Alex
[TechBlog] http://devkids.blogspot.com

> Where (within the CustomControl) should code to wire up base on the
> Custom Property for the Label.Text and TextBox.DataBindings be
[quoted text clipped - 49 lines]
>>>> P> to hard-wire the Label.Text for each Label for textbox?
>>>> P

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.