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 / March 2006

Tip: Looking for answers? Try searching our database.

Format event in DataBinding 2.0

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
herbert - 05 Mar 2006 11:21 GMT
I created a DataSource for a Web Service.
Then drag&Drop the text boxes for the return values onto the forms designer.
BindingSource is created everything OK.

Then I want to format the output of one of the text boxes.
Here is my VB.NET code to wire up an event handler:

           'get the Binding object for this textbox and setup the event
handler:
           Dim bind1 As Binding
           bind1 = TitleTextBox.DataBindings.Item(0)
           AddHandler bind1.Format, AddressOf OnTitleTextBoxFormat

The event handler is not called the first time when displaying a value of
the datasource. It works fine the 2nd, 3rd ... times, just the initial
display is wrong.

Imho the Format event should be fired too when the control gets an initial
output.

What would be the correct event to wire up?

thanks herbert
herbert - 05 Mar 2006 17:16 GMT
forgot: the code above is executed in Form1_Load
herbert
Lukky - 06 Mar 2006 15:55 GMT
Hi,

Just a thought, but is the call to add the handler made BEFORE filling the
table the first time ? If not, the Format event will indeed be called
whenever you modify the data, but not the first time that table is filled.

Regards,

Luc Morin

> I created a DataSource for a Web Service.
> Then drag&Drop the text boxes for the return values onto the forms designer.
[quoted text clipped - 19 lines]
>
> thanks herbert
herbert - 06 Mar 2006 20:15 GMT
Hi Lukky,

this is what I thought. However
1) How do I find out?
2) Isn't Form_Load supposed to be the first place to execute user-defined
code? At  least this is what the books say.
   So where should I get to the event beforehand? Mingle with the
designer-generated code?
Is there another way than the Format event where I can modify the bound
output ?

regards herbert

> Hi,
>
[quoted text clipped - 29 lines]
> >
> > thanks herbert
herbert - 06 Mar 2006 20:47 GMT
Lukky,

you're right! I found it:
I have to bind the DataBindingSource to the underlying data AFTER the event
handler is wired up.

   
Dim bind1 As Binding
bind1 = TitleTextBox.DataBindings.Item(0)
AddHandler bind1.Format, AddressOf OnTitleTextBoxFormat
ResultElementsBindingSource.DataSource = r.resultElements  'bind to result
from Web Service

Thank you, herbert

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.