Re: Text Box Controls Data Bound on Tab Controls

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Andrew McKendrick (andréwém_at_cogéco.ca)
Date: 07/01/04


Date: Thu, 1 Jul 2004 11:11:29 -0400

Hi Cor,

I made a mistake, in my reply post (on the newsgroup). I thought that your
code worked, but it never. The only reason it worked is because I clicked
the second tab and then the first tab (by displaying the second tab the
value in that field was loaded).

But try adding the following code segment to the Form_Click event and when
you run your code DO NOT click the second tab, but click the form instead
and you'll see the message box displays either an empty string or "textbox2"
depending on what the text value of the text box was at design time and NOT
"Hello" as it should.
MessageBox.Show("I am textbox2 and the value = " & TextBox2.Text)

Let me know if you experience something different, because if you do, either
you are misunderstanding me, or something is wrong with my copy of .NET :-)

Thanks,

Andrew

"Cor Ligthert" <notfirstname@planet.nl> wrote in message
news:upMRntzXEHA.3596@tk2msftngp13.phx.gbl...
> Hi Andrew,
>
> I tried to simulate your bug, can you tell me what is different in your
> situation because with this everything goes even better than I expected?
>
> Cor
>
> \\\a form with a tabcontrol with 2 tabpages with on each a textbox
> Dim bool As Boolean
> Private Sub Form1_Load(ByVal sender As Object, _
> ByVal e As System.EventArgs) Handles MyBase.Load
> Dim dt As New DataTable
> dt.Columns.Add("my")
> Dim dr As DataRow = dt.NewRow
> dr(0) = "Hello"
> dt.Rows.Add(dr)
> Me.TextBox1.DataBindings.Add("text", dt, "my")
> Me.TextBox2.DataBindings.Add("text", dt, "my")
> bool = True
> End Sub
> Private Sub TabControl1_SelectedIndexChanged(ByVal _
> sender As Object, ByVal e As System.EventArgs) Handles _
> TabControl1.SelectedIndexChanged
> If bool Then
> Select Case TabControl1.SelectedIndex
> Case 0
> MessageBox.Show("I am textbox2 and the value = " &
> TextBox2.Text)
> Case 1
> MessageBox.Show("I am textbox1 and the value = " &
> TextBox1.Text)
> End Select
> End If
> End Sub
> ///
>
> ,
> >
> > I've noticed a bug in VB.NET (latest .NET Framework)...
> >
> > - I have a TabControl on a form with several tabs.
> > - Each tab contains text boxes that are bound to fields in a data source
> > (DataBindings).
> > - When I display a record and then try to access the .Text property of
one
> > of the text boxes on any tab except the current tab, the result is an
> Empty
> > string.
> >
> > This occurs even though the fields that the text boxes are bound to have
> > data in them. If I display the tab and then try to read the contents of
> the
> > Text Boxes, then the data is there.
> >
> > Anyone know if there is a work around to this? Some way to force the
text
> > boxes to grab the data before they are displayed?
> >
> > Thanks in advance,
> >
> > Andrew
> >
> >
> >
>
>



Relevant Pages

  • Re: Return act like TAB in textboxes?
    ... not in all cases I didn't change Return; just for the data entry text ... boxes, of which there are 7 consecutive boxes in a row. ... For the case of the text boxes only, Return = Tab. ... KeyAscii = Asc)) ...
    (microsoft.public.vb.general.discussion)
  • Wierd behavior of combo boxes on tab control
    ... I have some very strange issues with combo boxes on a tab control. ... When you switch to that tab, ALL of these six combo boxes I ...
    (microsoft.public.dotnet.languages.vb)
  • Re: formatting styles for textboxes word 2007
    ... SmartArt follows Theme Effects which are ... I've been experimenting with using it instead of text boxes since they ... What you can do is insert the first SmartArt graphic in the Gallery ... wrapping can be found on the Format contextual tab for SmartArt under ...
    (microsoft.public.word.docmanagement)
  • Re: How can I not save certain data?
    ... Card text box, ... control is one that has a field in the Record Source as its Control Source. ... Click the Event tab, and click next to On Current. ... Repeat for other unbound text boxes. ...
    (microsoft.public.access.forms)
  • Re: Newbie to javascript
    ... textareas and dropdown boxes. ... dropdown boxes instead of tabbing up this tabs down. ... was set up for users to use the tab key. ... I seemed to have confused you slightly with the Tabbing up part of my ...
    (comp.lang.javascript)