stackoverflow on EndCurrentEdit

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Wan

    stackoverflow on EndCurrentEdit

    Dear Group,
    I have a small application with two buttons and three textboxes
    with databinding.
    One of the textboxes has a ¡§textchanged¡¨ event and other 2 textboxes
    are attached with the same events. If I type into any textboxes then
    btnSave and btnExit will enable/disable respectively. The problem is
    that in some instances ¡¥text changed event¡¨ hits endless loop and
    causes an stackoverflow message. Is there a way to solve this
    problem? I¡¦d appreciate any help. Thanks

    Private sub Form1_Activated (..)
    ¡K
    Text1.Databindi ngs.Add(New Binding(¡§Text¡ ¨, ds.tables(0), ¡§City¡¨)
    Text2.Databindi ngs.Add(New Binding(¡§Text¡ ¨, ds.tables(0), ¡§State¡¨)
    Text3.Databindi ngs.Add(New Binding(¡§Text¡ ¨, ds.tables(0), ¡§Zip¡¨)

    Addhander Text1.TexChnage d, AddressOf Form1_TextChang ed
    Addhander Text2.TexChnage d, AddressOf Form1_TextChang ed
    Addhander Text3.TexChnage d, AddressOf Form1_TextChang ed
    End sub

    Private sub Form1_TextChang ed(..) Handles textbox1_TextCh anged
    Me.bindingCntac t(ds).EndCurren tEdit() „² causes endless lop
    If ds.HasChanged = True then
    btnSave.Enabled = True ¡¥ enable save button
    btnExit.Enabled = False ¡¥ disable exit button
    Endif
    End sub

  • Alan Mosley

    #2
    Re: stackoverflow on EndCurrentEdit

    It would seem that changing text fires the event that changes text that once
    again fires event.

    You may need to record the value and see if it is fact diffrent to the new
    value, and if not then cancel the event

    "Wan" <wandii@yahoo.c omwrote in message
    news:9d169e1a-8c6c-48e4-83d1-e5ee0662bdc0@w1 g2000prd.google groups.com...
    Dear Group,
    I have a small application with two buttons and three textboxes
    with databinding.
    One of the textboxes has a ¡§textchanged¡¨ event and other 2 textboxes
    are attached with the same events. If I type into any textboxes then
    btnSave and btnExit will enable/disable respectively. The problem is
    that in some instances ¡¥text changed event¡¨ hits endless loop and
    causes an stackoverflow message. Is there a way to solve this
    problem? I¡¦d appreciate any help. Thanks

    Private sub Form1_Activated (..)
    ¡K
    Text1.Databindi ngs.Add(New Binding(¡§Text¡ ¨, ds.tables(0), ¡§City¡¨)
    Text2.Databindi ngs.Add(New Binding(¡§Text¡ ¨, ds.tables(0), ¡§State¡¨)
    Text3.Databindi ngs.Add(New Binding(¡§Text¡ ¨, ds.tables(0), ¡§Zip¡¨)

    Addhander Text1.TexChnage d, AddressOf Form1_TextChang ed
    Addhander Text2.TexChnage d, AddressOf Form1_TextChang ed
    Addhander Text3.TexChnage d, AddressOf Form1_TextChang ed
    End sub

    Private sub Form1_TextChang ed(..) Handles textbox1_TextCh anged
    Me.bindingCntac t(ds).EndCurren tEdit() „² causes endless lop
    If ds.HasChanged = True then
    btnSave.Enabled = True ¡¥ enable save button
    btnExit.Enabled = False ¡¥ disable exit button
    Endif
    End sub


    Comment

    • Jack Jackson

      #3
      Re: stackoverflow on EndCurrentEdit

      On Fri, 18 Jul 2008 00:02:36 -0700 (PDT), Wan <wandii@yahoo.c om>
      wrote:
      >Dear Group,
      I have a small application with two buttons and three textboxes
      >with databinding.
      >One of the textboxes has a ??textchanged?? event and other 2 textboxes
      >are attached with the same events. If I type into any textboxes then
      >btnSave and btnExit will enable/disable respectively. The problem is
      >that in some instances ??text changed event?? hits endless loop and
      >causes an stackoverflow message. Is there a way to solve this
      >problem? I??d appreciate any help. Thanks
      >
      >Private sub Form1_Activated (..)
      ?K
      Text1.Databindi ngs.Add(New Binding(??Text? ?, ds.tables(0), ??City??)
      Text2.Databindi ngs.Add(New Binding(??Text? ?, ds.tables(0), ??State??)
      Text3.Databindi ngs.Add(New Binding(??Text? ?, ds.tables(0), ??Zip??)
      >
      Addhander Text1.TexChnage d, AddressOf Form1_TextChang ed
      Addhander Text2.TexChnage d, AddressOf Form1_TextChang ed
      Addhander Text3.TexChnage d, AddressOf Form1_TextChang ed
      >End sub
      >
      >Private sub Form1_TextChang ed(..) Handles textbox1_TextCh anged
      Me.bindingCntac t(ds).EndCurren tEdit() ?? causes endless lop
      If ds.HasChanged = True then
      btnSave.Enabled = True ?? enable save button
      btnExit.Enabled = False ?? disable exit button
      Endif
      >End sub
      You could have a flag in the form, like:
      Private m_textChangedAc tive As Boolean = False

      Private sub Form1_TextChang ed(..) Handles textbox1_TextCh anged
      If m_textChangedAc tive Then
      Return
      End If
      m_textChangedAc tive = True
      Me.bindingCntac t(ds).EndCurren tEdit() ?? causes endless lop
      If ds.HasChanged = True then
      btnSave.Enabled = True ?? enable save button
      btnExit.Enabled = False ?? disable exit button
      Endif
      m_textChangedAc tive = False
      End sub

      Comment

      Working...