Microsoft Developer Network > 포럼 홈 > Visual C# General > Would like to include a combobox in a loop (same combobox is used several times in a survey)
질문하기질문하기
 

답변됨Would like to include a combobox in a loop (same combobox is used several times in a survey)

  • 2009년 11월 4일 수요일 오후 5:31jclark89 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    I am attempting to write a survey in C# and would like to add a combobox to a loop.  The combobox is used several times in the survey, and rather than include the box several times would like to add that to a method that could be called, the item selected and the value from the selection returned to the calling question.

    My question is this:
    1.  How can I access the value of the combobox once a selection has been made?  I have tried using selected.Index, but have not had any success with it.

    Thank  you for any replies.

답변

  • 2009년 11월 4일 수요일 오후 5:54Rudedog2중재자사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨
    Depending upon how you fill the combobox, and what you info you need back you want to use one of the .....

    ComboBox .SelectedXXXX

    .... properties.  There are 3 of them. 

    SelectedItem
    SelectedText
    SelectedValue

    IntelliSense should make them appear for you as you type. 
    Change the Bold text to the name of your combobox instance.

    In many cases, just getting the SelectedText is easiest.
    The other properties return System.Objects that represent that actual item itself.
    Mark the best replies as answers. "Fooling computers since 1971."

모든 응답

  • 2009년 11월 4일 수요일 오후 5:54Rudedog2중재자사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨
    Depending upon how you fill the combobox, and what you info you need back you want to use one of the .....

    ComboBox .SelectedXXXX

    .... properties.  There are 3 of them. 

    SelectedItem
    SelectedText
    SelectedValue

    IntelliSense should make them appear for you as you type. 
    Change the Bold text to the name of your combobox instance.

    In many cases, just getting the SelectedText is easiest.
    The other properties return System.Objects that represent that actual item itself.
    Mark the best replies as answers. "Fooling computers since 1971."