Adding Combo Box Items

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

    Adding Combo Box Items

    Hi,
    I am new to .Net.

    I am using a Combo Box in my windows forms. I am adding the items by
    creating the instances and adding the same to the list.
    My questions/doubts are:
    1. If I have 25 to 30 options in each combo box and like that if we have 6
    or 7 combo boxes in a form, isnt it a problem in creating that number of
    instances everytime the form is opened/activated
    2. How do I dispose the Combo Box items.

    Your comments/response is greatly appreciated.

    thanks
    vb
  • W.G. Ryan eMVP

    #2
    Re: Adding Combo Box Items

    Svae the datasource in a module or a shared property as a class. Then, just
    set the datasource of the combobox to this value - set the displaymember and
    valuemember properties accordingly.

    You're abosultely right though - reloading this each time is a pig - but if
    you just load a dataset at init and then use a shared property, you're good
    to go.

    --
    W.G. Ryan MVP (Windows Embedded)

    TiBA Solutions
    www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
    "vb" <vb@discussions .microsoft.com> wrote in message
    news:CA08E539-2EAF-4B75-902B-5FC585014328@mi crosoft.com...[color=blue]
    > Hi,
    > I am new to .Net.
    >
    > I am using a Combo Box in my windows forms. I am adding the items by
    > creating the instances and adding the same to the list.
    > My questions/doubts are:
    > 1. If I have 25 to 30 options in each combo box and like that if we have 6
    > or 7 combo boxes in a form, isnt it a problem in creating that number of
    > instances everytime the form is opened/activated
    > 2. How do I dispose the Combo Box items.
    >
    > Your comments/response is greatly appreciated.
    >
    > thanks
    > vb[/color]


    Comment

    • W.G. Ryan eMVP

      #3
      Re: Adding Combo Box Items

      Svae the datasource in a module or a shared property as a class. Then, just
      set the datasource of the combobox to this value - set the displaymember and
      valuemember properties accordingly.

      You're abosultely right though - reloading this each time is a pig - but if
      you just load a dataset at init and then use a shared property, you're good
      to go.

      --
      W.G. Ryan MVP (Windows Embedded)

      TiBA Solutions
      www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
      "vb" <vb@discussions .microsoft.com> wrote in message
      news:CA08E539-2EAF-4B75-902B-5FC585014328@mi crosoft.com...[color=blue]
      > Hi,
      > I am new to .Net.
      >
      > I am using a Combo Box in my windows forms. I am adding the items by
      > creating the instances and adding the same to the list.
      > My questions/doubts are:
      > 1. If I have 25 to 30 options in each combo box and like that if we have 6
      > or 7 combo boxes in a form, isnt it a problem in creating that number of
      > instances everytime the form is opened/activated
      > 2. How do I dispose the Combo Box items.
      >
      > Your comments/response is greatly appreciated.
      >
      > thanks
      > vb[/color]


      Comment

      • Cor Ligthert

        #4
        Re: Adding Combo Box Items

        VB,

        When there is used a datagridcombobo xcolomn, than there are mostly a lot
        more comboboxes as you now tell on a form.

        I never heard a complain in this newsgroup.

        Never think about disposing when you do not need to do it, it can be usefull
        to clear bitmaps something faster because they are mostly huge
        memoryspenders.

        Relaeasing resources is one of the reasons dotNet is made.

        Just my thought,


        Cor

        "vb" <vb@discussions .microsoft.com>
        [color=blue]
        > Hi,
        > I am new to .Net.
        >
        > I am using a Combo Box in my windows forms. I am adding the items by
        > creating the instances and adding the same to the list.
        > My questions/doubts are:
        > 1. If I have 25 to 30 options in each combo box and like that if we have 6
        > or 7 combo boxes in a form, isnt it a problem in creating that number of
        > instances everytime the form is opened/activated
        > 2. How do I dispose the Combo Box items.
        >
        > Your comments/response is greatly appreciated.
        >
        > thanks
        > vb[/color]


        Comment

        • Cor Ligthert

          #5
          Re: Adding Combo Box Items

          VB,

          When there is used a datagridcombobo xcolomn, than there are mostly a lot
          more comboboxes as you now tell on a form.

          I never heard a complain in this newsgroup.

          Never think about disposing when you do not need to do it, it can be usefull
          to clear bitmaps something faster because they are mostly huge
          memoryspenders.

          Relaeasing resources is one of the reasons dotNet is made.

          Just my thought,


          Cor

          "vb" <vb@discussions .microsoft.com>
          [color=blue]
          > Hi,
          > I am new to .Net.
          >
          > I am using a Combo Box in my windows forms. I am adding the items by
          > creating the instances and adding the same to the list.
          > My questions/doubts are:
          > 1. If I have 25 to 30 options in each combo box and like that if we have 6
          > or 7 combo boxes in a form, isnt it a problem in creating that number of
          > instances everytime the form is opened/activated
          > 2. How do I dispose the Combo Box items.
          >
          > Your comments/response is greatly appreciated.
          >
          > thanks
          > vb[/color]


          Comment

          • Herfried K. Wagner [MVP]

            #6
            Re: Adding Combo Box Items

            "vb" <vb@discussions .microsoft.com> schrieb:[color=blue]
            > I am using a Combo Box in my windows forms. I am adding
            > the items by creating the instances and adding the same to
            > the list.
            > My questions/doubts are:
            > 1. If I have 25 to 30 options in each combo box and like that
            > if we have 6 or 7 combo boxes in a form, isnt it a problem in
            > creating that number of instances everytime the form is
            > opened/activated[/color]

            What problems do you think of? There may be performance problems if you are
            adding hundreds of items when the form is shown, and maybe there will be
            memory problems if you are adding a large number of elements.
            [color=blue]
            > 2. How do I dispose the Combo Box items.[/color]

            Simply remove them from the combobox and dispose them, if they implement
            'IDisposable'.

            --
            Herfried K. Wagner [MVP]
            <URL:http://dotnet.mvps.org/>


            Comment

            • Herfried K. Wagner [MVP]

              #7
              Re: Adding Combo Box Items

              "vb" <vb@discussions .microsoft.com> schrieb:[color=blue]
              > I am using a Combo Box in my windows forms. I am adding
              > the items by creating the instances and adding the same to
              > the list.
              > My questions/doubts are:
              > 1. If I have 25 to 30 options in each combo box and like that
              > if we have 6 or 7 combo boxes in a form, isnt it a problem in
              > creating that number of instances everytime the form is
              > opened/activated[/color]

              What problems do you think of? There may be performance problems if you are
              adding hundreds of items when the form is shown, and maybe there will be
              memory problems if you are adding a large number of elements.
              [color=blue]
              > 2. How do I dispose the Combo Box items.[/color]

              Simply remove them from the combobox and dispose them, if they implement
              'IDisposable'.

              --
              Herfried K. Wagner [MVP]
              <URL:http://dotnet.mvps.org/>


              Comment

              Working...