Home Forums WinForms controls Other WinForms controls WinComboBox Columns?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #18267 |

    Hi All, I am loading a WinComboBox with a dataset returned from SQL Server with the following code:

    “SELECT RecordID, WeekEnding, Posted FROM tblWeekEnding”

    For Each pdrDataRow As DataRow In pdsWeekEnding.Tables(“tblWeekEnding”).Rows
    pdtPosted = pdrDataRow(“WeekEnding”)
    If pdrDataRow(“Posted”) Then
    cboWeekEnding.Items.Add(pdrDataRow(“RecordID”).ToString, pdtPosted.ToString(“MM/dd/yyyy”), “Posted”)
    Else
    cboWeekEnding.Items.Add(pdrDataRow(“RecordID”).ToString, pdtPosted.ToString(“MM/dd/yyyy”), “”)
    End If
    Next

    In the properties of the WinComboBox I have 3 columns (colRecordID, colWeekEnding, and colPosted”) and I have set the column colRecordID to Visible=False. The WinComboBox loads fine and displays fine. I can also select items in the WinComboBox.

    What I cant figure out is how to get the value in the RecordID column which is invisible after a selection is made.

    Any help?

    Thanks a million,
    Roy

    Imported from legacy forums. Posted by Roy (had 2133 views)

    User (Old forums)
    Member
    Post count: 23064

    You need to set the ValueMember property to the RecordID column/field. Then you can simply query the SelectedValue property to get the value.

    Imported from legacy forums. Posted by André (had 3208 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.