Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Create DataView and Bind to a Combobox

$
0
0

Using Visual Studio Community 2015

Windows 8.1 on 64 bit machine

I have a simple Windows Forms project where I have created a Data Source "BagTimeDataSet" from a local Access database and saved the Connection string to the Project file.  The dB contains a number of tables including the Suppliers table.

I wish to create a DataView from the dB Suppliers table using all the available records, Sort that view on Supplier Name and use that Dataview as the DataSource for a Comboxbox as per below;

Try
            Dim viewSup As New DataView(BagTimeDataSet.Tables("Suppliers"), "SupId >= 1", "SupName ASC", DataViewRowState.ModifiedCurrent)

            cboTabOrdersSupplier.DataSource = viewSup
            cboTabOrdersSupplier.DisplayMember = "SupName"
            cboTabOrdersSupplier.ValueMember = "SupId"

        Catch ex As Exception
            MessageBox.Show("Error :  " & ex.Message, "Form Load", MessageBoxButtons.OK)
        End Try

Trouble is I get 2 error messages;

ErrorBC30469Reference to a non-shared member requires an object reference.

ErrorBC32016'Public ReadOnly Property Tables As DataTableCollection' has no parameters and its return type cannot be indexed.

What am I doing wrong or missing?

TIA,

John





Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>