Hello Everyone,
I have a database that has some items and I would like to fill a combo box with the items and have the combobox selected value set the corresponding item ID. I have seen so many ways to do this I am not sure which way to go. Any help is appreciated. This is what I have so far:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace DBApp
{
public partial class Form1 : Form
{
DB db;
public Form1()
{
DataSet ds;
db = new DB();
ds = db.getRecords();
InitializeComponent();
comboBox1.DataSource = ds;
comboBox1.DisplayMember = "PlatformName";
comboBox1.ValueMember = "PlatformID";
}
}
}
With the code above an exception gets thrown:
The error is:
Cannot bind to the new display member.
Parameter name: newDisplayMember
Thanks.