BeginUpdate doesn't work in Listbox

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

    BeginUpdate doesn't work in Listbox

    I am using the following code:

    URLListBox.Begi nUpdate()
    URLListBox.Data Source = DSContent '.Tables("Conte ntSites")
    URLListBox.Disp layMember = "ContentSites.S iteName"
    URLListBox.Valu eMember = "ContentSites.U RL"
    URLListBox.EndU pdate()
    The program execution insistis on going to the Sub
    URLListBox_Sele ctedIndexChange d after the 2nd line (URLListBox.Dat aSource
    =...) It does this for each item in the DataSet. Isn't this exactly what
    BeginUpdate is supposed to prevent?

    Thanx,
    --
    Anil Gupte
    Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving




  • Armin Zingler

    #2
    Re: BeginUpdate doesn't work in Listbox

    "Anil Gupte" <anil-list@icinema.co mschrieb
    I am using the following code:
    >
    URLListBox.Begi nUpdate()
    URLListBox.Data Source = DSContent '.Tables("Conte ntSites")
    URLListBox.Disp layMember = "ContentSites.S iteName"
    URLListBox.Valu eMember = "ContentSites.U RL"
    URLListBox.EndU pdate()
    The program execution insistis on going to the Sub
    URLListBox_Sele ctedIndexChange d after the 2nd line
    (URLListBox.Dat aSource =...) It does this for each item in the
    DataSet. Isn't this exactly what BeginUpdate is supposed to
    prevent?
    No, it has nothing to do with events. It only defines whether the view
    is immediatelly refreshed as soon as the listbox' content changes. This
    is because doing a lot of consequtive operations affecting the view
    would cause a refresh after each operation. This costs performance.
    To avoid this, you can suppress the refresh by calling beginupdate, do
    the operations, and call Endupdate afterwards. This makes the listbox
    refresh only once, at EndUpdate, after all operations have been done.

    Armin

    Comment

    • Anil Gupte

      #3
      Re: BeginUpdate doesn't work in Listbox

      So how do I prevent the code execution from going to the
      _SelectedIndexC hanged when I am populating the listbox?

      Thanx for your help.
      --
      Anil Gupte
      Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving



      "Armin Zingler" <az.nospam@free net.dewrote in message
      news:O6%23VaQPi IHA.1208@TK2MSF TNGP03.phx.gbl. ..
      "Anil Gupte" <anil-list@icinema.co mschrieb
      >I am using the following code:
      >>
      > URLListBox.Begi nUpdate()
      > URLListBox.Data Source = DSContent '.Tables("Conte ntSites")
      >URLListBox.Dis playMember = "ContentSites.S iteName"
      > URLListBox.Valu eMember = "ContentSites.U RL"
      > URLListBox.EndU pdate()
      >The program execution insistis on going to the Sub
      >URLListBox_Sel ectedIndexChang ed after the 2nd line
      >(URLListBox.Da taSource =...) It does this for each item in the
      >DataSet. Isn't this exactly what BeginUpdate is supposed to
      >prevent?
      >
      No, it has nothing to do with events. It only defines whether the view
      is immediatelly refreshed as soon as the listbox' content changes. This
      is because doing a lot of consequtive operations affecting the view
      would cause a refresh after each operation. This costs performance.
      To avoid this, you can suppress the refresh by calling beginupdate, do
      the operations, and call Endupdate afterwards. This makes the listbox
      refresh only once, at EndUpdate, after all operations have been done.
      >
      Armin
      >

      Comment

      • Armin Zingler

        #4
        Re: BeginUpdate doesn't work in Listbox

        "Anil Gupte" <anil-list@icinema.co mschrieb
        So how do I prevent the code execution from going to the
        _SelectedIndexC hanged when I am populating the listbox?
        I don't know, I don't use data binding. I'd set a flag before filling
        the listbox and clear it afterwards. In the event handler, immediatelly
        exit the procedure if the flag is set.


        Armin

        Comment

        • Steven

          #5
          Re: BeginUpdate doesn't work in Listbox

          RemoveHandler URLListBox.Sele ctedIndexChange d, AddressOf
          URLListBox_Sele ctedIndexChange d
          URLListBox.Disp layMember = "ContentSites.S iteName"
          URLListBox.Valu eMember = "ContentSites.U RL"
          URLListBox.Data Source = DSContent '.Tables("Conte ntSites")
          AddHandler URLListBox.Sele ctedIndexChange d, AddressOf
          URLListBox_Sele ctedIndexChange d


          "Anil Gupte" <anil-list@icinema.co mwrote in message
          news:ucVIQbMiIH A.5504@TK2MSFTN GP05.phx.gbl...
          >I am using the following code:
          >
          URLListBox.Begi nUpdate()
          URLListBox.Data Source = DSContent '.Tables("Conte ntSites")
          URLListBox.Disp layMember = "ContentSites.S iteName"
          URLListBox.Valu eMember = "ContentSites.U RL"
          URLListBox.EndU pdate()
          The program execution insistis on going to the Sub
          URLListBox_Sele ctedIndexChange d after the 2nd line (URLListBox.Dat aSource
          =...) It does this for each item in the DataSet. Isn't this exactly what
          BeginUpdate is supposed to prevent?
          >
          Thanx,
          --
          Anil Gupte
          Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving


          >
          >

          Comment

          Working...