Combo Help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?QW5keSBD?=

    Combo Help

    Hi,

    Does anyone have an example code snippet from a Windows App that loads a
    field from a strongly typed DataSet into a Combobox? Even dissecting the
    DataSet via the Immediate Pane I still can't work out what part of the
    DataSet I need to load.

    Thanks very much.

    Andy
  • ClayB

    #2
    Re: Combo Help

    Maybe code like this will work for you.

    // Attach dataset.DataTab le's DefaultView to the
    combobox
    comboBox1.DataS ource =
    dataSet.Tables["customers"].DefaultView;
    comboBox1.Displ ayMember = "CustomerID ";

    ==============
    Clay Burch
    Syncfusion, Inc.




    Comment

    • RobinS

      #3
      Re: Combo Help

      You should have fields listed in the code-behind for your strongly typed
      dataset.

      If you are using data binding, you can bind the ValueMember and
      DisplayMember to the appropriate fields. For example, for a Customers
      dataset, I might set them like this:

      CustomersDataSe t dataSource = new CustomersDataSe t();
      CustomersTableA dapter adapter = new CustomersTableA dapter();
      adapter.Fill(da taSource);
      myCombo.DataSou rce = dataSource.Cust omers;
      myCombo.Display Member = "CompanyNam e";
      myCombo.ValueMe mber = "CustomerID "

      Is that what you mean, or do you want to literally load them?

      Robin S.
      -----------------------------------------------------------------
      "Andy C" <AndyC@discussi ons.microsoft.c omwrote in message
      news:AA1C6B8D-6A2F-480A-B679-3619BB11233B@mi crosoft.com...
      Hi,
      >
      Does anyone have an example code snippet from a Windows App that loads a
      field from a strongly typed DataSet into a Combobox? Even dissecting the
      DataSet via the Immediate Pane I still can't work out what part of the
      DataSet I need to load.
      >
      Thanks very much.
      >
      Andy

      Comment

      • =?Utf-8?B?QW5keSBD?=

        #4
        Re: Combo Help

        Thanks - I've worked out how to do this - I didn't want to bind them directly
        - I go through the list adding them as I need to but thanks for replying.

        Comment

        Working...