0
私はsqlのテーブルを持っています。そのカラムは:ID、EmpNo、NameおよびUsertypeです。 DataGridViewのコンボボックスにコンボボックスのsqlテーブルからdatagridviewへデータを取得
をUsertpye列のデータを取得する方法
のみUSERTYPEは、事前に
おかげでコンボボックスです。
私はsqlのテーブルを持っています。そのカラムは:ID、EmpNo、NameおよびUsertypeです。 DataGridViewのコンボボックスにコンボボックスのsqlテーブルからdatagridviewへデータを取得
をUsertpye列のデータを取得する方法
のみUSERTYPEは、事前に
おかげでコンボボックスです。
以下のコードを試してみてください。そういうものが欲しいと思います。
using System.Data.SqlServerCe;
string sqlConnection = "Data Source";
SqlCeConnection conn = new SqlCeConnection(sqlConnection);
conn.Open();
//Get bind from database.
string qryGetCategory = "Query to get data for combo box";
SqlCeCommand cmdCat = new SqlCeCommand(qryGetCategory, conn);
SqlCeDataAdapter daCat = new SqlCeDataAdapter(qryGetCategory, conn);
DataTable dtCat = new DataTable();
daCat.Fill(dtCat);
//Combobox column.
DataGridViewComboBoxColumn ComboBoxCol = new DataGridViewComboBoxColumn();
ComboBoxCol.DataSource = dtCat;
ComboBoxCol.Name = "Column name";
ComboBoxCol.ValueMember = "Value of member";
ComboBoxCol.DisplayMember = "Member to be show";
datagridview.Columns.Add(ComboBoxCol);
ご質問やご質問がございましたら、お気軽にお問い合わせください。
@LeoJbあなたが役に立ったと思ったら、答えとしてマークしてください。 –
DGVをどのように使用しているのかによって異なります – Plutonix
あなたは以下の意味ですか? 1)コンボボックスにUsertype列の値をバインドします。2)そのコンボボックスをdatagridviewの中に置きます。 –
DataGridviewに配置する方法は? – LeoJb