テキストボックスに入力する値Iに基づいて複数のデータを表示します。 Iは、CASAのテキストボックスに入力= 200とCASBテキストボックス= 200、WSID 1234及び5678が示される場合C#を使用して複数のデータをDatagridviewに表示
WSID CasA CasB
1234 200 100
5678 300 200
0987 400 300
6543 500 400
:私のようなデータを持っています。私は上記のような値を入力すれば、CasBのWSIDを表示するだけで問題はあります。誰でも助けてくれますか?
string lokasinectar = LokasiNectar.Text;
string koneksinectar = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + lokasinectar + ";Extended Properties='Excel 12.0 xml;HDR=YES;IMEX=1';";
int thresholdcasa;
Int32.TryParse(CasA.Text, out thresholdcasa);
int thresholdcasb;
Int32.TryParse(CasB.Text, out thresholdcasb);
OleDbConnection kon = new OleDbConnection(koneksinectar);
DataTable dt = new DataTable();
OleDbDataAdapter adapter = new OleDbDataAdapter("select [WSID], [CasA], [CasB] from [Sheet1$]", kon);
DataSet coba = new DataSet();
adapter.Fill(coba);
var table = coba.Tables[0];
var view = new DataView(table);
if (CasAChk.Checked)
{
if (CasA.Text.Length > 0)
{
view.RowFilter = string.Format("[CasA] = '{0}'", thresholdcasa);
}
}
else if (CasBChk.Checked)
{
if (CasB.Text.Length > 0)
{
view.RowFilter = string.Format("[CasB] ='{0}'", thresholdcasb);
}
}
ViewNectarGV.DataSource = view;
コードはいつ実行されますか?例えばイベント中かどうか。チェックボックスをオンにしたら? – jambonick