private void Form1_Load(object sender, EventArgs e) { DataTable dt = new DataTable(); dt.Columns.Add("Name"); dt.Columns.Add("Value"); dt.Rows.Add("北京", "Y"); dt.Rows.Add("上海", "N"); dt.Rows.Add("南京", "N"); dt.Rows.Add("哈尔滨", "N"); myOptions1.Columns = 1; myOptions1.BindData(dt); ((MyOptionsColumn)dataGridView1.Columns["Column1"]).DataSource = dt; dataGridView1.Rows.Add(); dataGridView1.Rows[0].Cells[0].Value = "哈尔滨"; dataGridView1.Columns[0].DefaultCellStyle.Format = ""; dataWindow1.Retrieve("1"); DataWindow dw = dataWindow1; dw.setitem(0, "pihao", "aaaaa"); }
public long f_delt_dw_row(ref DataWindow adw_dw, ref long al_focuschanged, long al_xuhao) { if (al_xuhao >= 0) { if (MessageBox.Show("您确实要删除吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return(-1); } } al_focuschanged = 666; //多行删除选中行后导致的焦点改变 long ll_i, ll_count; ll_count = adw_dw.rowcount(); if (adw_dw.Tag.ToString().Substring(0, 1) == "3") // 单行删除 { if (ll_count == 1) { if (f_delt_dw_pre_file(ref adw_dw, ll_count) == -1) { return(-1); } adw_dw.deleterow(1); } } else // 多行删除 { //for (ll_i = ll_count; ll_i >= 1; ll_i--) //{ // if (adw_dw.IsSelected(ll_i)) // { // if (f_delt_dw_pre_file(ref adw_dw, ll_i) == -1) // return -1; // adw_dw.deleterow(ll_i); // } //} for (int i = adw_dw.dataGridView1.SelectedRows.Count - 1; i >= 0; i--) { if (f_delt_dw_pre_file(ref adw_dw, adw_dw.dataGridView1.SelectedRows[i].Index) == -1) { return(-1); } adw_dw.deleterow(adw_dw.dataGridView1.SelectedRows[i].Index); } } al_focuschanged = 0; //al_xuhao // 1代表有序号的需要重新更改序号 0代表没有序号的跳过 负数代表不提示直接删除 if (al_xuhao == 1) { string ls_colname, ls_sort = ""; //ls_sort = adw_dw.title; ls_colname = adw_dw.Cols[0].Name; f_dwsort(adw_dw, ls_colname + " A"); for (ll_i = 0; ll_i < adw_dw.rowcount(); ll_i++) { if (adw_dw.GetItemData(ll_i, ls_colname) != ll_i.ToString()) { adw_dw.setitem(ll_i, ls_colname, ll_i + 1); } } f_dwsort(adw_dw, ls_sort); } return(1); }