private void butMoi_Click(object sender, System.EventArgs e) { int i = 1; DataRow r; dtkp = m.get_data("select * from " + user + ".btdkp_bv order by makp").Tables[0]; for (i = 1; i < 100; i++) { r = m.getrowbyid(dtkp, "makp='" + i.ToString().PadLeft(2, '0') + "'"); if (r == null) { break; } } ma.Text = i.ToString().PadLeft(2, '0'); viettat.Text = ma.Text; for (int k = 0; k < dmba.Items.Count; k++) { dmba.SetItemCheckState(k, CheckState.Unchecked); } giavtth.Text = s_loaivp = s_mucvp = ten.Text = ""; thucke.Text = "0"; kehoach.Text = "0"; s_loaicd = s_muccd = ""; ena_object(true); ma.Enabled = false; viettat.Focus(); }
private void butMoi_Click(object sender, System.EventArgs e) { int i = 1; dtkp = m.get_data("select * from " + user + ".btdkp_bv order by makp").Tables[0]; DataRow r; for (i = 1; i < 100; i++) { r = m.getrowbyid(dtkp, "makp='" + i.ToString().PadLeft(2, '0') + "'"); if (r == null) { break; } } ma.Text = i.ToString().PadLeft(2, '0'); viettat.Text = ma.Text; s_loaivp = ""; s_mucvp = ""; ten.Text = ""; s_loaicd = ""; s_muccd = ""; for (i = 0; i < maba.Items.Count; i++) { maba.SetItemCheckState(i, CheckState.Unchecked); } ena_object(true); viettat.Focus(); }
public void mostrarServicios(ref CheckedListBox miCombo, string t_primera,string t_eco,string t_turista) { miCombo.Items.Add("Primera Clase"); miCombo.Items.Add("Ejecutivo"); miCombo.Items.Add("Turista"); if (t_primera == "Sí") { miCombo.SetItemCheckState(0, CheckState.Checked); } if (t_eco == "Sí") { miCombo.SetItemCheckState(1, CheckState.Checked); } if (t_turista == "Sí") { miCombo.SetItemCheckState(2, CheckState.Checked); } }
private void loai_SelectedIndexChanged(object sender, System.EventArgs e) { s_loai = ""; s_phieu = ""; for (int i = 0; i < loai.Items.Count; i++) { if (loai.GetItemChecked(i)) { s_loai += dtloai.Rows[i]["id"].ToString().Trim() + ","; } } if (s_loai != "") { for (int i = 0; i < phieu.Items.Count; i++) { if (phieu.GetItemChecked(i)) { s_phieu += dtphieu.Rows[i]["id"].ToString().Trim() + ","; } } sql = "select a.id,trim(b.ten)||'//'||trim(a.ten) as ten from " + user + ".d_loaiphieu a," + user + ".d_dmphieu b where a.loai=b.id "; sql += " and (a.loai in (" + s_loai.Substring(0, s_loai.Length - 1) + ")"; sql += " and a.nhom=" + i_nhom; if (s_loai.IndexOf("3,") != -1) { sql += " or (a.id=0 and a.loai=3)"; } sql += ")"; sql += " order by a.loai,a.stt"; dtphieu = d.get_data(sql).Tables[0]; } else { dtphieu = d.get_data("select * from " + user + ".d_loaiphieu where id=-1").Tables[0]; } phieu.DataSource = dtphieu; phieu.DisplayMember = "TEN"; phieu.ValueMember = "ID"; if (s_phieu != "") { for (int i = 0; i < phieu.Items.Count; i++) { if (s_phieu.IndexOf(dtphieu.Rows[i]["id"].ToString().Trim() + ",") != -1) { phieu.SetItemCheckState(i, CheckState.Checked); } else { phieu.SetItemCheckState(i, CheckState.Unchecked); } } } }
private void chkAll_Click(object sender, System.EventArgs e) { for (int i = 0; i < makp.Items.Count; i++) { if (chkAll.Checked) { makp.SetItemCheckState(i, CheckState.Checked); } else { makp.SetItemCheckState(i, CheckState.Unchecked); } } }
//</Snippet2> //<Snippet4> //<Snippet3> private void CheckEveryOther_Click(object sender, System.EventArgs e) { // Cycle through every item and check every other. // Set flag to true to know when this code is being executed. Used in the ItemCheck // event handler. insideCheckEveryOther = true; for (int i = 0; i < checkedListBox1.Items.Count; i++) { // For every other item in the list, set as checked. if ((i % 2) == 0) { // But for each other item that is to be checked, set as being in an // indeterminate checked state. if ((i % 4) == 0) { checkedListBox1.SetItemCheckState(i, CheckState.Indeterminate); } else { checkedListBox1.SetItemChecked(i, true); } } } insideCheckEveryOther = false; }
private void frmChonvp_Load(object sender, System.EventArgs e) { user = m.user; dc = new DataColumn(); dc.DataType = System.Type.GetType("System.Decimal"); dc.ColumnName = "ma"; dt.Columns.Add(dc); int j = 0; while (j < s_mucvp.Length) { updrec(decimal.Parse(s_mucvp.Substring(j, 7))); j += 8; } dtloai = m.get_data("select * from " + user + ".v_loaivp order by stt").Tables[0]; loai.DataSource = dtloai; loai.DisplayMember = "TEN"; loai.ValueMember = "ID"; for (int i = 0; i < dtloai.Rows.Count; i++) { if (s_loaivp.IndexOf(dtloai.Rows[i]["id"].ToString().Trim().PadLeft(3, '0') + ",") != -1) { loai.SetItemCheckState(i, CheckState.Checked); } } if (loai.Items.Count > 0) { load_mavp(long.Parse(loai.SelectedValue.ToString())); } }
private void Chech_phieu() { for (int i = 0; i < loai.Items.Count; i++) { if (dtloai.Rows[i]["id"].ToString() == i_loai.ToString()) { loai.SetItemCheckState(i, CheckState.Checked); break; } } dtphieu = d.get_data("select * from " + user + ".d_loaiphieu where nhom=" + int.Parse(nhom.SelectedValue.ToString()) + " and loai in (" + i_loai + ")" + " order by stt").Tables[0]; phieu.DataSource = dtphieu; phieu.DisplayMember = "TEN"; phieu.ValueMember = "ID"; for (int i = 0; i < phieu.Items.Count; i++) { if (dtphieu.Rows[i]["id"].ToString() == i_phieu.ToString()) { phieu.SetItemCheckState(i, CheckState.Checked); break; } } for (int i = 0; i < makho.Items.Count; i++) { makho.SetItemCheckState(i, CheckState.Checked); } }
private void butIn_Click(object sender, System.EventArgs e) { s_makp = "'"; if (makp.CheckedItems.Count == 0) { for (int i = 0; i < makp.Items.Count; i++) { makp.SetItemCheckState(i, CheckState.Checked); } } for (int i = 0; i < makp.Items.Count; i++) { if (makp.GetItemChecked(i)) { s_makp += dtkp.Rows[i]["makp"].ToString() + "','"; } } s_makp = (s_makp != "")?s_makp.Substring(0, s_makp.Length - 2):""; ds = exp.get_thngtru(tu.Text, den.Text, s_makp, time.Checked); if (ds.Tables[0].Rows.Count > 0) { frmReport f = new frmReport(m, ds, (tu.Text == den.Text)?"Ngày " + tu.Text:"Từ ngày " + tu.Text + " đến " + den.Text, "rptthngtr.rpt", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); f.ShowDialog(); } else { MessageBox.Show(lan.Change_language_MessageText("Không có số liệu !"), LibMedi.AccessData.Msg); } }
private void bDetails_Click( object sender, System.EventArgs e ) { PacketItem pi = clbPackets.SelectedItem as PacketItem; if ( pi != null ) { PacketProp[] props = Packet.PropsTable[pi.Cmd]; string[] names = new string[props.Length]; string[] typeNames = new String[props.Length]; string[] formats = new string[props.Length]; for ( int i = 0; i < props.Length; i++ ) { names[i] = props[i].PropInfo.Name; typeNames[i] = props[i].PropInfo.PropertyType.Name; formats[i] = props[i].Attribute.Format; } PropsFilter pFilter = new PropsFilter( names, typeNames, pi.Props, pi.PropsHave, formats ); pFilter.TopMost = TopMost; if ( pFilter.ShowDialog() == DialogResult.OK ) { pi.Props = pFilter.GetPropValues(); pi.PropsHave = pFilter.GetPropHaveValues(); clbPackets.SetItemCheckState( clbPackets.SelectedIndex, GetCheckState( pi ) ); } } }
private bool kiemtra() { s_kho = ""; if (kho.CheckedItems.Count == 0) { for (int i = 0; i < kho.Items.Count; i++) { kho.SetItemCheckState(i, CheckState.Checked); } } for (int i = 0; i < kho.Items.Count; i++) { if (kho.GetItemChecked(i)) { s_kho += dtdmkho.Rows[i]["id"].ToString() + ","; } } sql = "select * from ttb_dmkho where nhom=" + i_nhom; if (s_kho != "") { sql += " and id in (" + s_kho.Substring(0, s_kho.Length - 1) + ")"; } if (s_makho != "") { sql += " and id in (" + s_makho.Substring(0, s_makho.Length - 1) + ")"; } sql += " order by stt"; dtkho = ttb.get_data(sql).Tables[0]; Tao_dataset(); // // DateTime dt1 = ttb.StringToDate(tu.Text).AddDays(-ttb.iNgaykiemke); DateTime dt2 = ttb.StringToDate(den.Text).AddDays(ttb.iNgaykiemke); int y1 = dt1.Year, m1 = dt1.Month; int y2 = dt2.Year, m2 = dt2.Month; int itu, iden; string mmyy = ""; for (int i = y1; i <= y2; i++) { itu = (i == y1)?m1:1; iden = (i == y2)?m2:12; for (int j = itu; j <= iden; j++) { mmyy = j.ToString().PadLeft(2, '0') + i.ToString().Substring(2, 2); if (ttb.bMmyy(mmyy)) { get_xuat(mmyy); get_hoantra(mmyy); } } } if (ds.Tables[0].Rows.Count == 0) { MessageBox.Show("Không có số liệu !", ttb.Msg); return(false); } return(true); }
private bool kiemtra() { if (tu.Value > den.Value) { MessageBox.Show( lan.Change_language_MessageText("Tháng không hợp lệ !"), d.Msg); tu.Focus(); return(false); } s_makho = ""; if (kho.CheckedItems.Count == 0) { for (int i = 0; i < kho.Items.Count; i++) { kho.SetItemCheckState(i, CheckState.Checked); } } for (int i = 0; i < kho.Items.Count; i++) { if (kho.GetItemChecked(i)) { s_makho += dtkho.Rows[i]["id"].ToString() + ","; } } dtdmkho = d.get_data("select * from " + user + ".d_dmkho where hide=0 and nhom=" + i_nhom + " and id in (" + s_makho.Substring(0, s_makho.Length - 1) + ") order by stt").Tables[0]; Tao_dataset(); s_mmyy = tu.Value.ToString().PadLeft(2, '0') + yyyy.Value.ToString().PadLeft(4, '0').Substring(2, 2); s_tu = tu.Value.ToString().PadLeft(2, '0'); s_den = den.Value.ToString().PadLeft(2, '0'); s_yy = yyyy.Value.ToString().PadLeft(4, '0').Substring(2, 2); // int y1 = int.Parse(yyyy.Value.ToString()), m1 = int.Parse(tu.Value.ToString()); int y2 = int.Parse(yyyy.Value.ToString()), m2 = int.Parse(den.Value.ToString()); int itu, iden; string mmyy = ""; for (int i = y1; i <= y2; i++) { itu = (i == y1)?m1:1; iden = (i == y2)?m2:12; for (int j = itu; j <= iden; j++) { mmyy = j.ToString().PadLeft(2, '0') + i.ToString().Substring(2, 2); if (d.bMmyy(mmyy)) { get_nhap(mmyy); } } } // if (ds.Tables[0].Rows.Count == 0) { MessageBox.Show( lan.Change_language_MessageText("Không có số liệu !"), d.Msg); return(false); } return(true); }
private void checkBox1_Click(object sender, System.EventArgs e) { if (checkBox1.Checked == true) { for (int i = 0; i < dtdmkho.Rows.Count; i++) { kho.SetItemCheckState(i, CheckState.Checked); } } else { for (int i = 0; i < dtdmkho.Rows.Count; i++) { kho.SetItemCheckState(i, CheckState.Unchecked); } } }
private void butTiep_Click(object sender, System.EventArgs e) { mabn.Text = ""; hoten.Text = ""; namsinh.Text = ""; ngayra.Text = m.Ngaygio_hienhanh.Substring(0, 10); tenkp.Text = ""; makp.Text = ""; sothe.Text = ""; diachi.Text = ""; l_maql = 0; l_idkhoa = 0; for (int i = 0; i < madt.Items.Count; i++) { madt.SetItemCheckState(i, CheckState.Unchecked); } ena_but(true); mabn.Focus(); }
private void frmBaocaocstt_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { if (bClear) { s_makp = d.Thongso("d_thongso", "sudung").Trim(); for (int i = 0; i < makp.Items.Count; i++) { if (s_makp.IndexOf(dtkp.Rows[i]["id"].ToString().Trim() + ",") != -1) { makp.SetItemCheckState(i, CheckState.Checked); } else { makp.SetItemCheckState(i, CheckState.Unchecked); } } bClear = false; } }
private void ref_mavp() { for (int i = 0; i < dtmavp.Rows.Count; i++) { if (s_mucvp.IndexOf(dtmavp.Rows[i]["id"].ToString().Trim().PadLeft(7, '0') + ",") != -1) { mavp.SetItemCheckState(i, CheckState.Checked); } } }
private bool kiemtra() { s_kho = ""; s_loaikhac = ""; s_tenkho = ""; s_tenloai = ""; if (kho.CheckedItems.Count == 0) { for (int i = 0; i < kho.Items.Count; i++) { kho.SetItemCheckState(i, CheckState.Checked); } } for (int i = 0; i < kho.Items.Count; i++) { if (kho.GetItemChecked(i)) { s_kho += dtdmkho.Rows[i]["id"].ToString() + ","; s_tenkho += dtdmkho.Rows[i]["ten"].ToString().Trim() + ","; } } for (int i = 0; i < loai.Items.Count; i++) { if (loai.GetItemChecked(i)) { s_loaikhac += dtloai.Rows[i]["id"].ToString() + ","; s_tenloai += dtloai.Rows[i]["ten"].ToString().Trim() + ","; } } DateTime dt1 = d.StringToDate(tu.Text).AddDays(-d.iNgaykiemke); DateTime dt2 = d.StringToDate(den.Text).AddDays(d.iNgaykiemke); int y1 = dt1.Year, m1 = dt1.Month; int y2 = dt2.Year, m2 = dt2.Month; int itu, iden; string mmyy = ""; ds.Clear(); for (int i = y1; i <= y2; i++) { itu = (i == y1)?m1:1; iden = (i == y2)?m2:12; for (int j = itu; j <= iden; j++) { mmyy = j.ToString().PadLeft(2, '0') + i.ToString().Substring(2, 2); if (d.bMmyy(mmyy)) { get_xuat(mmyy); } } } if (ds.Tables[0].Rows.Count == 0) { MessageBox.Show( lan.Change_language_MessageText("Không có số liệu !"), d.Msg); return(false); } return(true); }
private void butMoi_Click(object sender, System.EventArgs e) { try { stt.Value = decimal.Parse(ttb.get_data("select max(madoituong) from " + table).Tables[0].Rows[0][0].ToString()) + 1; } catch { stt.Value = 1; } for (int k = 0; k < nguon.Items.Count; k++) { nguon.SetItemCheckState(k, CheckState.Unchecked); } for (int k = 0; k < manhom.Items.Count; k++) { manhom.SetItemCheckState(k, CheckState.Unchecked); } ten.Text = ""; loai.SelectedIndex = 0; ena_object(true); ten.Focus(); }
private void butMoi_Click(object sender, System.EventArgs e) { try { stt.Value = decimal.Parse(ttb.get_data("select max(stt) from " + user + ".ttb_nhomkhoa").Tables[0].Rows[0][0].ToString()) + 1; } catch { stt.Value = 1; } i_id = 0; ma.Text = ""; ten.Text = ""; for (int k = 0; k < makp.Items.Count; k++) { makp.SetItemCheckState(k, CheckState.Unchecked); } for (int k = 0; k < nhomkho.Items.Count; k++) { nhomkho.SetItemCheckState(k, CheckState.Unchecked); } ena_object(true); stt.Focus(); }
private void ref_mavp() { string tmp_mucvp = "," + s_mucvp.Trim().Trim(',') + ","; for (int i = 0; i < dtmavp.Rows.Count; i++) { if (tmp_mucvp.IndexOf("," + dtmavp.Rows[i]["id"].ToString().Trim() + ",") != -1) { mavp.SetItemCheckState(i, CheckState.Checked); } } }
private void rptBctheonhom_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { if (bClear) { manguon.SelectedIndex = -1; nhomcc.SelectedIndex = -1; string snhom = "," + s_manhom; for (int i = 0; i < dtdmnhom.Rows.Count; i++) { if (snhom.IndexOf("," + dtdmnhom.Rows[i]["id"].ToString().Trim() + ",") != -1) { manhom.SetItemCheckState(i, CheckState.Checked); } else { manhom.SetItemCheckState(i, CheckState.Unchecked); } } bClear = false; } }
private void Check_phieu_default() { for (int i = 0; i < phieudutru.Items.Count; i++) { if (dtphieu.Rows[i]["id"].ToString() == i_phieu.ToString()) { phieudutru.SetItemCheckState(i, CheckState.Checked); break; } } phieudutru.Enabled = false; }
private void butOk_Click(object sender, System.EventArgs e) { mmyy = mm.Value.ToString().PadLeft(2, '0') + yyyy.Value.ToString().PadLeft(4, '0').Substring(2, 2); if (!ttb.bMmyy(mmyy)) { MessageBox.Show("Số liệu tháng " + mmyy.Substring(0, 2) + " năm 20" + mmyy.Substring(2) + " chưa tạo !", ttb.Msg); mm.Focus(); return; } xxx = user;//+ mmyy; if (ttb.bKhoaso(i_nhom, mmyy)) { MessageBox.Show("Số liệu tháng " + mmyy.Substring(0, 2) + " năm " + mmyy.Substring(2, 2) + "\nĐã khóa không có phép thay đổi !", ttb.Msg); return; } if (makho.CheckedItems.Count == 0) { for (int i = 0; i < makho.Items.Count; i++) { makho.SetItemCheckState(i, CheckState.Checked); } } s_tenkho = ""; for (int i = 0; i < makho.Items.Count; i++) { if (makho.GetItemChecked(i)) { s_tenkho += dtkho.Rows[i]["ten"].ToString() + "\n"; } } if (MessageBox.Show("Bạn có đồng ý kiểm tra lại tồn đầu \n" + s_tenkho + "Tháng " + mmyy.Substring(0, 2) + " năm " + mmyy.Substring(2, 2), ttb.Msg, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { Cursor = Cursors.WaitCursor; string mmyyt = ttb.Mmyy_truoc(mmyy); if (!ttb.bKhoaso(i_nhom, mmyyt)) { ttb.upd_tonkho(mmyyt, i_nhom, 1); } for (int i = 0; i < makho.Items.Count; i++) { if (makho.GetItemChecked(i)) { ttb.upd_kiemtratondau(mmyy, int.Parse(dtkho.Rows[i]["id"].ToString()), i_userid); } } ttb.upd_tonkho(mmyy, i_nhom, 1); ttb.execute_data("delete from " + xxx + ".ttb_tonkhoct where tondau=0 and slnhap=0 and slxuat=0 and mmyy='" + mmyy + "'"); ttb.execute_data("delete from " + xxx + ".ttb_tonkhoth where tondau=0 and slnhap=0 and slxuat=0 and mmyy='" + mmyy + "'"); Cursor = Cursors.Default; MessageBox.Show("Đã kiểm tra lại tồn đầu \n" + s_tenkho, ttb.Msg); } }
private void butIn_Click(object sender, System.EventArgs e) { ds.Clear(); s_kho = ""; if (kho.CheckedItems.Count == 0) { for (int i = 0; i < kho.Items.Count; i++) { kho.SetItemCheckState(i, CheckState.Checked); } } for (int i = 0; i < kho.Items.Count; i++) { if (kho.GetItemChecked(i)) { s_kho += dtdmkho.Rows[i]["id"].ToString() + ","; } } // DateTime dt1 = d.StringToDate(tu.Text).AddDays(-d.iNgaykiemke); DateTime dt2 = d.StringToDate(den.Text).AddDays(d.iNgaykiemke); int y1 = dt1.Year, m1 = dt1.Month; int y2 = dt2.Year, m2 = dt2.Month; int itu, iden; string mmyy = ""; for (int i = y1; i <= y2; i++) { itu = (i == y1)?m1:1; iden = (i == y2)?m2:12; for (int j = itu; j <= iden; j++) { mmyy = j.ToString().PadLeft(2, '0') + i.ToString().Substring(2, 2); if (d.bMmyy(mmyy)) { get_xuat(mmyy); get_hoantra(mmyy); } } } if (ds.Tables[0].Rows.Count == 0) { MessageBox.Show( lan.Change_language_MessageText("Không có số liệu !"), d.Msg); return; } get_sort(); frmReport f = new frmReport(d, dsxml.Tables[0], i_userid, "d_duocbv.rpt", (tu.Text == den.Text)?" Ngày :" + tu.Text:"Từ ngày :" + tu.Text + " đến :" + den.Text, (kho.SelectedIndex == -1)?"":"Của kho :" + kho.Text, (manguon.SelectedIndex == -1)?"":"Nguồn :" + manguon.Text, (nhomcc.SelectedIndex == -1)?"":" Nhóm nhà cung cấp :" + nhomcc.Text, "DƯỢC BỆNH VIỆN", "", "", "", "", ""); f.ShowDialog(); }
private void butMoi_Click(object sender, System.EventArgs e) { int i = 1; DataRow r; DataTable tmp = m.get_data("select * from " + user + ".btdpmo order by ma").Tables[0]; for (i = 1; i < 100; i++) { r = m.getrowbyid(tmp, "ma='" + i.ToString().PadLeft(2, '0') + "'"); if (r == null) { break; } } ma.Text = i.ToString().PadLeft(2, '0'); for (int k = 0; k < makp.Items.Count; k++) { makp.SetItemCheckState(k, CheckState.Unchecked); } ten.Text = ""; ena_object(true); ma.Enabled = false; ten.Focus(); }
private void butMoi_Click(object sender, System.EventArgs e) { try { stt.Value = decimal.Parse(ttb.get_data("select max(stt) from " + user + ".ttb_dmphieu where nhom=" + i_nhom).Tables[0].Rows[0][0].ToString()) + 1; } catch { stt.Value = 1; } i_id = 0; ten.Text = ""; for (int k = 0; k < kho.Items.Count; k++) { kho.SetItemCheckState(k, CheckState.Unchecked); } for (int k = 0; k < nguon.Items.Count; k++) { nguon.SetItemCheckState(k, CheckState.Unchecked); } for (int k = 0; k < madoituong.Items.Count; k++) { madoituong.SetItemCheckState(k, CheckState.Unchecked); } ena_object(true); ten.Focus(); }
private void AddPieTheme() { FeatureLayer selected = layers.SelectedItem as FeatureLayer; if (selected != null) { // Collect list of columns to use: ArrayList list = new ArrayList(); for (int i = 0; i < fields.Items.Count; i++) { if (fields.GetItemCheckState(i) == CheckState.Checked) { list.Add(fields.Items[i]); } } // If there are any, then add the theme: if (list.Count > 0) { try { PieTheme theme = new PieTheme( mapControl1.Map, selected.Table, (string[])list.ToArray(typeof(string)) ); ObjectThemeLayer themeLayer = new ObjectThemeLayer( "World Pop Growth Rate", null, theme); mapControl1.Map.Layers.Add(themeLayer); theme.DataValueAtSize *= 2; theme.GraduateSizeBy = GraduateSizeBy.Constant; themeLayer.RebuildTheme(); } catch (Exception e) { for (int i = 0; i < fields.Items.Count; i++) { fields.SetItemCheckState(i, CheckState.Unchecked); } System.Windows.Forms.MessageBox.Show("Error: \n" + e.ToString(), "PieTheme Error"); } } } }
/// <summary> /// Event Handler from MoveUp and MoveDown Button Click. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnMove_Click(object sender, System.EventArgs e) { // Declare the current and destination indices of the // real time stylus plugin being moved. int currentIndex = chklbPlugins.SelectedIndex; int destinationIndex = -1; if ((0 <= currentIndex) && (currentIndex <= chklbPlugins.Items.Count)) { // Calculate the destination based on whether move up // or down was pressed. if (sender == btnMoveUp) { destinationIndex = currentIndex - 1; } else { destinationIndex = currentIndex + 1; } // The destination index of the plugin being moved must fall // within the bounds of the plugin list. if ((0 <= destinationIndex) && (destinationIndex < chklbPlugins.Items.Count)) { CheckState checkState = chklbPlugins.GetItemCheckState(currentIndex); // If the plugin being moved is currently enabled, // remove it from the plugin collection. if (CheckState.Checked == checkState) { RemoveFromPluginCollection(currentIndex); } // Update the checked list box to reflect the move. object item = chklbPlugins.Items[currentIndex]; chklbPlugins.Items.RemoveAt(currentIndex); chklbPlugins.Items.Insert(destinationIndex, item); // Restore the selected and checked state of the list item. chklbPlugins.SetSelected(destinationIndex, true); chklbPlugins.SetItemCheckState(destinationIndex, checkState); } } }
private void chkAllBones_CheckStateChanged_1(object sender, EventArgs e) { if (lstBones.Items.Count == 0) { return; } _updating = true; lstBones.BeginUpdate(); for (int i = 0; i < lstBones.Items.Count; i++) { lstBones.SetItemCheckState(i, chkAllBones.CheckState); } lstBones.EndUpdate(); _updating = false; _mainWindow.modelPanel1.Invalidate(); }
private void chkAllBones_CheckStateChanged(object sender, EventArgs e) { if (lstBones.Items.Count == 0) { return; } _updating = true; lstBones.BeginUpdate(); for (int i = 0; i < lstBones.Items.Count; i++) { lstBones.SetItemCheckState(i, chkAllBones.CheckState); } lstBones.EndUpdate(); _updating = false; if (RenderStateChanged != null) { RenderStateChanged(this, null); } }
private void get_data() { s_kho = ""; if (makho.CheckedItems.Count == 0) { for (int i = 0; i < makho.Items.Count; i++) { makho.SetItemCheckState(i, CheckState.Checked); } } for (int i = 0; i < makho.Items.Count; i++) { if (makho.GetItemChecked(i)) { s_kho += dtdmkho.Rows[i]["id"].ToString().Trim() + ","; } } tao_table(); s_mmyy = tu.Value.ToString().PadLeft(2, '0') + yyyy.Value.ToString().PadLeft(4, '0').Substring(2, 2); int itu = Convert.ToInt16(tu.Value), iden = Convert.ToInt16(den.Value); for (int i = itu; i <= iden; i++) { s_mmyy = i.ToString().PadLeft(2, '0') + yyyy.Value.ToString().PadLeft(4, '0').Substring(2, 2); if (d.bMmyy(s_mmyy)) { items_nhap(s_mmyy); } } if (ds.Tables[0].Rows.Count == 0) { MessageBox.Show(lan.Change_language_MessageText("Không có số liệu !"), d.Msg); return; } get_sort(); exp_excel(false); }
private static void ClearAllCheckState(CheckedListBox clb) { for(int i = 0; i < clb.Items.Count; i++) { clb.SetItemCheckState(i, CheckState.Unchecked); } }
private static void SetAllCheckedListItems(CheckedListBox listBox, CheckState state) { for (int index = 0; index < listBox.Items.Count; index++) listBox.SetItemCheckState(index, state); }
/// <summary> /// Left mouse click: check/uncheck the item. /// Middle mouse click: remove item. /// Right mouse click: send item from chList1 to chList2. /// </summary> /// <param name="chList1"> The handled checkedListBox. </param> /// <param name="chList2"> The dual checkedListBox. </param> /// <param name="e"> The mouse click event. </param> public static void DualChListMouseEvent(CheckedListBox chList1, CheckedListBox chList2, MouseEventArgs e, Point mousePosition, bool useDual = true) { if (e.Button == System.Windows.Forms.MouseButtons.Right) { for (int i = 0; i < chList1.Items.Count; i++) { if (i != 0 || useDual) { if (chList1.GetItemRectangle(i).Contains(chList1.PointToClient(mousePosition))) { chList2.AddOrderedFromBottom(chList1.GetText(i), chList1.GetItemChecked(i)); chList1.Items.RemoveAt(i); } } } } else if (e.Button == System.Windows.Forms.MouseButtons.Middle) { for (int i = 0; i < chList1.Items.Count; i++) { if (i != 0 || useDual) { if (chList1.GetItemRectangle(i).Contains(chList1.PointToClient(mousePosition))) { chList1.Items.RemoveAt(i); } } } } else if (e.Button == System.Windows.Forms.MouseButtons.Left) { for (int i = 0; i < chList1.Items.Count; i++) { if (chList1.GetItemRectangle(i).Contains(chList1.PointToClient(mousePosition))) { switch (chList1.GetItemCheckState(i)) { case CheckState.Checked: chList1.SetItemCheckState(i, CheckState.Unchecked); break; case CheckState.Indeterminate: case CheckState.Unchecked: chList1.SetItemCheckState(i, CheckState.Checked); break; } } } } }
//CheckedListBox für die Zuordnung von Stimmungen und Klamotten public static DialogResult showKlamotteStimmungCLBMask(ref string[] stimmungen_set, string[] stimmungen_all, string klamotte_bezeichnung) { // Form System.Drawing.Size size = new System.Drawing.Size(300, 150); Form stimmungen_clb = new Form(); stimmungen_clb.FormBorderStyle = FormBorderStyle.Fixed3D; stimmungen_clb.ClientSize = size; stimmungen_clb.Text = "w2w - Stimmungen für " + klamotte_bezeichnung + " zuordnen:"; // Checklistboxen CheckedListBox clb = new CheckedListBox(); clb.Size = new System.Drawing.Size(size.Width - 10, 100); clb.Location = new System.Drawing.Point(5, 5); clb.Items.AddRange(stimmungen_all); clb.CheckOnClick = true; stimmungen_clb.Controls.Add(clb); // Buttons Button cancelButton = new Button(); cancelButton.DialogResult = DialogResult.Cancel; cancelButton.Name = "cancelButton"; cancelButton.Size = new System.Drawing.Size(70, 30); cancelButton.Text = "&Abbrechen"; cancelButton.Location = new System.Drawing.Point(size.Width - 80, clb.Location.Y + clb.Size.Height + 10); stimmungen_clb.Controls.Add(cancelButton); Button deleteButton = new Button(); deleteButton.DialogResult = DialogResult.OK; deleteButton.Name = "okButton"; deleteButton.Size = new System.Drawing.Size(70, 30); deleteButton.Text = "&OK"; deleteButton.Location = new System.Drawing.Point(size.Width - 80 - 80, clb.Location.Y + clb.Size.Height + 10); stimmungen_clb.Controls.Add(deleteButton); // Zuweisen der Buttons zu Ereignissen stimmungen_clb.AcceptButton = deleteButton; stimmungen_clb.CancelButton = cancelButton; stimmungen_clb.StartPosition = FormStartPosition.CenterParent; for (int i = 0; i < clb.Items.Count; i++) { if (stimmungen_set.Contains(clb.Items[i].ToString())) { clb.SetItemCheckState(i, CheckState.Checked); } } // Anzeigen des Dialogs DialogResult result = stimmungen_clb.ShowDialog(); // Überschreiben der Referenz mit Inhalt der Eingabebox Array.Clear(stimmungen_set, 0, stimmungen_set.Length); Array.Resize(ref stimmungen_set, clb.CheckedItems.Count); clb.CheckedItems.CopyTo(stimmungen_set, 0); // Zurückgeben des Dialog Ergebnisses return result; }
/// <summary> /// 全部取选中方法 /// </summary> /// <param name="chckList">控件对象</param> public void CheckAllEsce(CheckedListBox ckl) { for (int i = 0; i < ckl.Items.Count; i++)//遍历控件中的项并赋值 { ckl.SetItemCheckState(i, CheckState.Unchecked); } }
private void btnMoveUp_Click(object sender, System.EventArgs e) { int index = chkLstFields.SelectedIndices[0]; if(index!=0) { ArrayList list = new ArrayList(); CheckedListBox cb = new CheckedListBox(); cb.Items.AddRange(chkLstFields.Items); for(int i=0; i<chkLstFields.CheckedItems.Count; i++) { cb.SetItemCheckState(cb.Items.IndexOf(chkLstFields.CheckedItems[i]),CheckState.Checked); } list.AddRange(chkLstFields.Items); ArrayList newlist = new ArrayList(list); newlist[index] = list[index-1]; newlist[index-1] = list[index]; chkLstFields.Items.Clear(); chkLstFields.Items.AddRange((string[])newlist.ToArray(typeof(string))); for(int i=0; i<cb.CheckedItems.Count; i++) { chkLstFields.SetItemCheckState(chkLstFields.Items.IndexOf(cb.CheckedItems[i]),CheckState.Checked); } chkLstFields.SelectedItem = chkLstFields.Items[index-1]; } }
public void SetItemCheckStateTest () { Form myform = new Form (); myform.ShowInTaskbar = false; myform.Visible = true; CheckedListBox mychklistbox = new CheckedListBox (); mychklistbox.Items.Add ("test1"); mychklistbox.Items.Add ("test2"); mychklistbox.Items.Add ("test3"); mychklistbox.Visible = true; myform.Controls.Add (mychklistbox); mychklistbox.SetItemCheckState (0,CheckState.Checked); mychklistbox.SetItemCheckState (1,CheckState.Indeterminate); mychklistbox.SetItemCheckState (2,CheckState.Unchecked); Assert.AreEqual (CheckState.Checked, mychklistbox.GetItemCheckState (0), "#19"); Assert.AreEqual (CheckState.Indeterminate, mychklistbox.GetItemCheckState (1), "#20"); Assert.AreEqual (CheckState.Unchecked, mychklistbox.GetItemCheckState (2), "#21"); myform.Dispose (); }
private static void SetCheckState(CheckedListBox clb, string value, CheckState state) { int index = 0; foreach(object item in clb.Items) { if(item.ToString() == value) { clb.SetItemCheckState(index, state); return; } index++; } }
public static void limpiarCheckboxList(CheckedListBox cbl) { foreach (int i in cbl.CheckedIndices) { cbl.SetItemCheckState(i, CheckState.Unchecked); cbl.SetSelected(i,false); } }
private void copyPanelItems(Tuple<string, Func<int, int, int>, int, int, int, int, int>[] panelSrc, CheckedListBox listSrc, Tuple<string, Func<int, int, int>, int, int, int, int, int>[] panelDest, CheckedListBox listDest) { for (int a = 0; a < panelSrc.Length; a++) { if (panelSrc[a] != null) { // copy panel item panelDest[a] = new Tuple<string,Func<int,int,int>,int,int,int,int,int>( panelSrc[a].Item1, panelSrc[a].Item2, panelSrc[a].Item3, panelSrc[a].Item4, panelSrc[a].Item5, panelSrc[a].Item6, panelSrc[a].Item7); // copy checked item list listDest.SetItemCheckState(a, listSrc.GetItemCheckState(a)); } else { panelDest[a] = null; } } }