ListBox Item Objects: what is displayed?

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

    ListBox Item Objects: what is displayed?

    I'm going to be using a ListBox in my managed C++ application, and have a
    question. Why are the Items you Add to a ListBox in the form of generic
    Object*'s? I believe a ListBox displays a table of selectable options via
    multiple lines (or columns) of TEXT, so why doesn't Add merely take a
    String* ? How does it know what to display (i.e., the text of each Item
    listing) with a generic Object* (or do all Object's have some Text property
    ListBox knows to display to represent it)? Put more to the point, if I Add
    an Item which ISN'T a String*, what does the ListBox display?

    Thanks in advance! : )

    [==Peteroid==]


  • mosimu

    #2
    RE: ListBox Item Objects: what is displayed?

    You should look up DisplayMember and ValueMember, which are listbox
    properties. I have never used it myself but you can use that to control what
    is displayed in the listbox.

    mosimu

    "Peteroid" wrote:
    [color=blue]
    > I'm going to be using a ListBox in my managed C++ application, and have a
    > question. Why are the Items you Add to a ListBox in the form of generic
    > Object*'s? I believe a ListBox displays a table of selectable options via
    > multiple lines (or columns) of TEXT, so why doesn't Add merely take a
    > String* ? How does it know what to display (i.e., the text of each Item
    > listing) with a generic Object* (or do all Object's have some Text property
    > ListBox knows to display to represent it)? Put more to the point, if I Add
    > an Item which ISN'T a String*, what does the ListBox display?
    >
    > Thanks in advance! : )
    >
    > [==Peteroid==]
    >
    >
    >[/color]

    Comment

    • Peteroid

      #3
      Re: ListBox Item Objects: what is displayed?

      Thanks, I will :)

      [==Peteroid==]

      "mosimu" <mosimu@discuss ions.microsoft. com> wrote in message
      news:7BA4C578-226C-4793-871E-1F4BCF798D1C@mi crosoft.com...[color=blue]
      > You should look up DisplayMember and ValueMember, which are listbox
      > properties. I have never used it myself but you can use that to control
      > what
      > is displayed in the listbox.
      >
      > mosimu
      >
      > "Peteroid" wrote:
      >[color=green]
      >> I'm going to be using a ListBox in my managed C++ application, and have a
      >> question. Why are the Items you Add to a ListBox in the form of generic
      >> Object*'s? I believe a ListBox displays a table of selectable options via
      >> multiple lines (or columns) of TEXT, so why doesn't Add merely take a
      >> String* ? How does it know what to display (i.e., the text of each Item
      >> listing) with a generic Object* (or do all Object's have some Text
      >> property
      >> ListBox knows to display to represent it)? Put more to the point, if I
      >> Add
      >> an Item which ISN'T a String*, what does the ListBox display?
      >>
      >> Thanks in advance! : )
      >>
      >> [==Peteroid==]
      >>
      >>
      >>[/color][/color]


      Comment

      Working...