ComboBox Blank Entry

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

    #1

    ComboBox Blank Entry

    Without adding whitespace to the ComboBox datasource is there a way I can add
    a blank entry or, a reset entry, to the ComboBox dropdown

    Thanks
    Steve
  • Mark Rae

    #2
    Re: ComboBox Blank Entry

    "Steve B." <SteveB@discuss ions.microsoft. com> wrote in message
    news:A970DA60-BFF7-48DB-B66D-6125F4685598@mi crosoft.com...
    [color=blue]
    > Without adding whitespace to the ComboBox datasource is there a way I can
    > add
    > a blank entry or, a reset entry, to the ComboBox dropdown[/color]

    Not sure what you mean by whitespace - if you add a blank entry to a
    ComboBox, that's exactly what it will be - a blank entry...


    Comment

    • Otis Mukinfus

      #3
      Re: ComboBox Blank Entry

      On Sat, 11 Feb 2006 14:32:31 -0800, "Steve B."
      <SteveB@discuss ions.microsoft. com> wrote:
      [color=blue]
      >Without adding whitespace to the ComboBox datasource is there a way I can add
      >a blank entry or, a reset entry, to the ComboBox dropdown
      >
      >Thanks
      >Steve[/color]
      If you mean you want to add a value to index zero of the combo box,
      the way to do that is to populate the combo from the data source and
      then add it by doing this:

      private void FillButton_Clic k(object sender, EventArgs e)
      {
      string[] items = { "One", "Two", "Three" };

      TestComboBox.It ems.AddRange(it ems);
      TestComboBox.It ems.Insert(0, "Top Item");
      TestComboBox.Se lectedIndex = 0;
      }


      Otis Mukinfus


      Comment

      • Steve B.

        #4
        Re: ComboBox Blank Entry

        Thanks Mark/Otis for replying

        My datasource is a database table.

        Lets say the datasource for the CB dropdown is a database table of colors.
        If the user selects the color "Red" in the dropdown and then changes his mind
        later and decides not to select a any kind of color his only choice is to
        backspace to remove his previous "Red" selection. I wanted to give the user
        a choice to select a blank entry in the dropdown menu. I didn't want to add
        a blank row to the database (bad practice).

        Mark, I'm going to do some tests regarding your code

        Thanks
        Steve

        "Otis Mukinfus" wrote:
        [color=blue]
        > On Sat, 11 Feb 2006 14:32:31 -0800, "Steve B."
        > <SteveB@discuss ions.microsoft. com> wrote:
        >[color=green]
        > >Without adding whitespace to the ComboBox datasource is there a way I can add
        > >a blank entry or, a reset entry, to the ComboBox dropdown
        > >
        > >Thanks
        > >Steve[/color]
        > If you mean you want to add a value to index zero of the combo box,
        > the way to do that is to populate the combo from the data source and
        > then add it by doing this:
        >
        > private void FillButton_Clic k(object sender, EventArgs e)
        > {
        > string[] items = { "One", "Two", "Three" };
        >
        > TestComboBox.It ems.AddRange(it ems);
        > TestComboBox.It ems.Insert(0, "Top Item");
        > TestComboBox.Se lectedIndex = 0;
        > }
        >
        >
        > Otis Mukinfus
        > http://www.otismukinfus.com
        > http://www.tomchilders.com
        >[/color]

        Comment

        • Otis Mukinfus

          #5
          Re: ComboBox Blank Entry

          On Sun, 12 Feb 2006 11:56:03 -0800, "Steve B."
          <SteveB@discuss ions.microsoft. com> wrote:
          [color=blue]
          >Thanks Mark/Otis for replying
          >
          >My datasource is a database table.
          >
          >Lets say the datasource for the CB dropdown is a database table of colors.
          >If the user selects the color "Red" in the dropdown and then changes his mind
          >later and decides not to select a any kind of color his only choice is to
          >backspace to remove his previous "Red" selection. I wanted to give the user
          >a choice to select a blank entry in the dropdown menu. I didn't want to add
          >a blank row to the database (bad practice).
          >
          >Mark, I'm going to do some tests regarding your code
          >
          >Thanks
          >Steve
          >
          >"Otis Mukinfus" wrote:
          >[color=green]
          >> On Sat, 11 Feb 2006 14:32:31 -0800, "Steve B."
          >> <SteveB@discuss ions.microsoft. com> wrote:
          >>[color=darkred]
          >> >Without adding whitespace to the ComboBox datasource is there a way I can add
          >> >a blank entry or, a reset entry, to the ComboBox dropdown
          >> >
          >> >Thanks
          >> >Steve[/color]
          >> If you mean you want to add a value to index zero of the combo box,
          >> the way to do that is to populate the combo from the data source and
          >> then add it by doing this:
          >>
          >> private void FillButton_Clic k(object sender, EventArgs e)
          >> {
          >> string[] items = { "One", "Two", "Three" };
          >>
          >> TestComboBox.It ems.AddRange(it ems);
          >> TestComboBox.It ems.Insert(0, "Top Item");
          >> TestComboBox.Se lectedIndex = 0;
          >> }
          >>
          >>
          >> Otis Mukinfus
          >> http://www.otismukinfus.com
          >> http://www.tomchilders.com
          >>[/color][/color]
          Change "Top Item" to "" and you will get a blank entry in the first
          row. Then when the user selects an item from the ComboBox you can do
          the appropriate thing based on the selected index.

          Otis Mukinfus


          Comment

          • Steve B.

            #6
            Re: ComboBox Blank Entry

            I'll try it thank you Otis

            --Steve

            "Otis Mukinfus" wrote:
            [color=blue]
            > On Sun, 12 Feb 2006 11:56:03 -0800, "Steve B."
            > <SteveB@discuss ions.microsoft. com> wrote:
            >[color=green]
            > >Thanks Mark/Otis for replying
            > >
            > >My datasource is a database table.
            > >
            > >Lets say the datasource for the CB dropdown is a database table of colors.
            > >If the user selects the color "Red" in the dropdown and then changes his mind
            > >later and decides not to select a any kind of color his only choice is to
            > >backspace to remove his previous "Red" selection. I wanted to give the user
            > >a choice to select a blank entry in the dropdown menu. I didn't want to add
            > >a blank row to the database (bad practice).
            > >
            > >Mark, I'm going to do some tests regarding your code
            > >
            > >Thanks
            > >Steve
            > >
            > >"Otis Mukinfus" wrote:
            > >[color=darkred]
            > >> On Sat, 11 Feb 2006 14:32:31 -0800, "Steve B."
            > >> <SteveB@discuss ions.microsoft. com> wrote:
            > >>
            > >> >Without adding whitespace to the ComboBox datasource is there a way I can add
            > >> >a blank entry or, a reset entry, to the ComboBox dropdown
            > >> >
            > >> >Thanks
            > >> >Steve
            > >> If you mean you want to add a value to index zero of the combo box,
            > >> the way to do that is to populate the combo from the data source and
            > >> then add it by doing this:
            > >>
            > >> private void FillButton_Clic k(object sender, EventArgs e)
            > >> {
            > >> string[] items = { "One", "Two", "Three" };
            > >>
            > >> TestComboBox.It ems.AddRange(it ems);
            > >> TestComboBox.It ems.Insert(0, "Top Item");
            > >> TestComboBox.Se lectedIndex = 0;
            > >> }
            > >>
            > >>
            > >> Otis Mukinfus
            > >> http://www.otismukinfus.com
            > >> http://www.tomchilders.com
            > >>[/color][/color]
            > Change "Top Item" to "" and you will get a blank entry in the first
            > row. Then when the user selects an item from the ComboBox you can do
            > the appropriate thing based on the selected index.
            >
            > Otis Mukinfus
            > http://www.otismukinfus.com
            > http://www.tomchilders.com
            >[/color]

            Comment

            Working...