databindings, label controls and tab controls -- problem

  • Thread starter Thread starter Tom Scales
  • Start date Start date
T

Tom Scales

OK, this one has me stumped. I am reading XML into a Dataset and then
binding values to a label control. When displayed on the screen, the label
control has the correct value in it.

When I read back the value from the label control, the text field is "".

But ONLY if the label field is on a tab in a tab control. If the label
field is on the main form, the code works!

Here's my example code:

------------------------
Public dsConfig As New DataSet

Try

dsConfig.ReadXml(AppPath() & "default.config.xml")

' OK, we're attached to our file, let's put the values into the label
control

lblPath.DataBindings.Add("text", dsConfig, "Config.ConfigPath")

lblConfig.DataBindings.Add("text", dsConfig, "Config.ConfigFile")

Catch ex As Exception

MsgBox("Error Loading default configuration", MsgBoxStyle.OKOnly +
MsgBoxStyle.Critical, "Critical error")

Me.Close() ' get the heck out!

End Try
---------------------------------

So, if lblPath or lblConfig is on a tab, then lblPath.Text is empty. If it
is on the main form, it has the proper value from the XML. Either way, it
displays properly on the form

Any solutions?

Thanks in advance,

Tom
 
Tom Scales said:
OK, this one has me stumped. I am reading XML into a Dataset and then
binding values to a label control. When displayed on the screen, the
label
control has the correct value in it.

When I read back the value from the label control, the text field is "".

But ONLY if the label field is on a tab in a tab control. If the label
field is on the main form, the code works!

Well, I don't often answer my own questions, but....

Turns out the problem is that the label field is not correctly updated until
the tab is actually shown. Seems like a bug to me, but easy to work around.

Tom
 
Back
Top