checkedListBox使用例子
? #region 初始化資料查詢界面
??????? public void InitFeelsInfoGrid()
??????? {
??????????? EatGood.Model.FoodManage.SearchFeelKind model = new EatGood.Model.FoodManage.SearchFeelKind();
??????????? model.FShopId = fshopid.ToString();
??????????? #region 動態組織SQL語句
??????????? string stre = null;
??????????? for (int i = 0; i < checkedListBox2.Items.Count; i++)
??????????? {
??????????????? if (checkedListBox2.GetItemChecked(i))
??????????????? {
??????????????????? stre += "FeelKindName in('" + checkedListBox2.GetItemText(checkedListBox2.Items[i]) + "') or ";
??????????????? }
??????????? }
??????????? if (stre != null)
??????????? {
??????????????? model.FeelKindName = strw + "(" + stre.Substring(0, stre.Length - 3) + ")";
??????????? }
??????????? stre = null;
??????????? for (int i = 0; i < checkedListBox3.Items.Count; i++)
??????????? {
??????????????? if (checkedListBox3.GetItemChecked(i))
??????????????? {
??????????????????? stre += "kindname in('" + checkedListBox3.GetItemText(checkedListBox3.Items[i]) + "') or ";
??????????????? }
??????????? }
??????????? if (stre != null)
??????????? {
??????????????? model.Kindname = strw + "(" + stre.Substring(0, stre.Length - 3) + ")";
??????????? }
??????????? #endregion
??????????? model.FeelNo = textBox1.Text.Trim();
??????????? model.FeelName = textBox2.Text.Trim();
??????????? SQL = model.GetSQLFromTempl();
??????????? DataSet ds = sfk.SearchFeelsInfo(SQL);
??????????? BindFeelsInfoGrid(ds);
??????? }
??????? private void BindFeelsInfoGrid(DataSet ds)
??????? {
??????????? SongTao3 st3 = new SongTao3();
??????????? st3.Show();
??????????? this.Hide();
??????????? if (checkBox1.Checked)
??????????? {
??????????????? st3.dataGridView1.DataSource = ds.Tables[0].DefaultView;
??????????? }
??????????? else
??????????? {
??????????????? st3.dataGridView1.DataSource = ds.Tables[0].DefaultView;
??????????????? st3.dataGridView1.Columns.Remove("comname");
??????????? }
??????? }
??????? #endregion?
轉載于:https://www.cnblogs.com/a1991322/archive/2012/08/22/2650714.html
總結
以上是生活随笔為你收集整理的checkedListBox使用例子的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C# 数据结构 之 堆栈和队列
- 下一篇: Guru of the Week 条款0