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
forgot: the code above is executed in Form1_Load
herbert
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