private void 除DToolStripMenuItem_Click(object sender, EventArgs e) { if (superGridControl1.GetSelectedRows().Count > 0) { SelectedElementCollection col = superGridControl1.GetSelectedRows(); if (col.Count > 0) { GridRow gridRow = col[0] as GridRow; try { int result = depm.FalseDelClear(gridRow["gridColumn2"].Value.ToString()); if (result == 1) { MessageBox.Show("删除成功!"); } else { MessageBox.Show("删除失败,请重试"); } } catch (Exception ex) { MessageBox.Show("删除异常,请检查服务器连接.异常信息:" + ex.Message); } } } else { MessageBox.Show("请先选择需要删除的信息"); } }
private void SGC_ToolPath_RowClick(object sender, GridRowClickEventArgs e) { //取得點選的RowIndex CurrentRowIndex = e.GridRow.Index; CurrentSelOperName = panel.GetCell(CurrentRowIndex, 0).Value.ToString(); SelectedElementCollection selRow = panel.GetSelectedElements(); ListSelOper = new List <string>(); foreach (GridRow item in selRow) { ListSelOper.Add(item.Cells[1].Value.ToString()); } NXOpen.CAM.Preferences preferences1 = theSession.CAMSession.CreateCamPreferences(); if (ListSelOper.Count == 1) { preferences1.ReplayRefreshBeforeEachPath = true; } else if (ListSelOper.Count > 1) { preferences1.ReplayRefreshBeforeEachPath = false; } preferences1.Commit(); preferences1.Destroy(); //UG顯示刀具路徑 ExportShopDocDlg cExportShopDocDlg = new ExportShopDocDlg(); cExportShopDocDlg.DisplayOpPath(ListSelOper); }
void LabelX_MarkupLinkClick(object sender, MarkupLinkClickEventArgs e) { SelectedElementCollection collection = this.usgSource.GetSelectedCells(); if (collection.Count > 0) { GridCell gridCell = collection[0] as GridCell; if (gridCell != null) { GridRow gridRow = gridCell.Parent as GridRow; if (gridRow != null) { frmReserveOperate frmReserveOperate = new frmReserveOperate(); frmReserveOperate.BringToFront(); frmReserveOperate.StartPosition = FormStartPosition.CenterScreen; frmReserveOperate.SourceBillGuid = gridRow.Cells["colSourceBillGuid"].Value.ToGuid(); frmReserveOperate.SourceBillLineGuid = gridRow.Cells["colSourceBillLineGuid"].Value.ToGuid(); frmReserveOperate.SourceBillNo = gridRow.Cells["colSourceBillNo"].Value.ToStringHasNull(); frmReserveOperate.SourceBillType = gridRow.Cells["colSourceBillType"].Value.ToStringHasNull(); frmReserveOperate.RefreshParentForm += delegate { BindSuperGrid(1); }; frmReserveOperate.ShowDialog(); } } } }
private void 编辑ToolStripMenuItem_Click(object sender, EventArgs e) { if (superGridControlStorage.GetSelectedRows().Count > 0) { Storage storage = new Storage(); SelectedElementCollection col = superGridControlStorage.GetSelectedRows(); if (col.Count > 0) { GridRow gridRow = col[0] as GridRow; storage.St_Address = gridRow["St_Address"].Value.ToString(); storage.St_Clear = Convert.ToInt32(gridRow["St_Clear"].Value); storage.St_Code = gridRow["St_Code"].Value.ToString(); storage.St_EmpName = gridRow["St_EmpName"].Value.ToString(); storage.St_Enable = Convert.ToInt32(gridRow["St_Enable"].Value); storage.St_ID = Convert.ToInt32(gridRow["St_ID"].Value); storage.St_Name = gridRow["St_Name"].Value.ToString(); storage.St_Phone = gridRow["St_Phone"].Value.ToString(); storage.St_Remark = gridRow["St_Remark"].Value.ToString(); storage.St_Safetyone = gridRow["St_Safetyone"].Value.ToString(); storage.St_Safetytwo = gridRow["St_Safetytwo"].Value.ToString(); } StorageCreateForm scf = new StorageCreateForm(); scf._update = true; scf._storage = storage; scf.ShowDialog(this); } else { MessageBox.Show("请先选择需要编辑的信息"); } }
/// <summary> /// Handles user requests to change each /// selected cells font /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnFontClick(object sender, EventArgs e) { FontDialog fd = new FontDialog(); fd.ShowColor = true; fd.ShowEffects = true; DialogResult result = fd.ShowDialog(); if (result == DialogResult.OK) { GridPanel panel = superGridControl1.PrimaryGrid; SelectedElementCollection items = panel.GetSelectedElements(); List <GridCell> cells = items.GetCells(); foreach (GridCell cell in cells) { if (cell.IsEmptyCell == false) { cell.GridRow.Cells[cell.ColumnIndex]. CellStyles.Default.Font = fd.Font; } } } }
private void 除ToolStripMenuItem_Click(object sender, EventArgs e) { if (superGridControlStorage.GetSelectedRows().Count > 0) { SelectedElementCollection col = superGridControlStorage.GetSelectedRows(); if (col.Count > 0) { StorageManager sm = new StorageManager(); GridRow gridRow = col[0] as GridRow; try { bool result = sm.DeleteFake(gridRow["St_Code"].Value.ToString()); if (result) { MessageBox.Show("删除成功!"); } else { MessageBox.Show("删除失败,请重试"); } } catch (Exception ex) { MessageBox.Show("删除异常,请检查服务器连接.异常信息:" + ex.Message); } } } else { MessageBox.Show("请先选择需要删除的信息"); } }
/// <summary> /// Handles the text update of all selected cells, when /// the user is entering txt in the toolbar textbox /// and hits the enter key. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TbxCellTextKeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { e.SuppressKeyPress = true; GridPanel panel = superGridControl1.PrimaryGrid; SelectedElementCollection items = panel.GetSelectedElements(); List <GridCell> cells = items.GetCells(); // See above comments about the difference in accessibility // between Empty cells and newly allocated ones. AllocateCells(cells); string s = TbxCellText.Text; foreach (GridCell cell in cells) { GridCell ncell = cell.GridRow.Cells[cell.ColumnIndex]; ncell.Value = s; ncell.GridRow.RowDirty = true; } } }
/// <summary> /// 删除按钮 转码code用于删除的where条件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 除DToolStripMenuItem_Click(object sender, EventArgs e) { if (superGridControl1.PrimaryGrid.GetSelectedRows() == null) { ClientTypeManager ctm = new ClientTypeManager(); SelectedElementCollection col = superGridControl1.PrimaryGrid.GetSelectedRows(); DialogResult dr = MessageBox.Show("确定要删除该数据吗?操作不可恢复", "请注意", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.No) { return; } GridRow row = col[0] as GridRow; string code = XYEEncoding. strCodeHex(row.Cells["TypeCode"].Value.ToString()); bool result = ctm.Delete(code); if (result) { loadData(); MessageBox.Show("客户类别删除成功"); } else { MessageBox.Show("删除失败,请检查是否选中列"); } } else { MessageBox.Show("请先选中要修改的数据所在行"); } }
void lxc_MarkupLinkClick(object sender, MarkupLinkClickEventArgs e) { SelectedElementCollection collection = this.noticedPanel.GetSelectedCells(); if (collection.Count > 0) { GridCell gridCell = collection[0] as GridCell; if (gridCell != null) { GridRow gridRow = gridCell.Parent as GridRow; if (gridRow != null) { if (MessageBox.Show("请确认是否通知采购员取消采购?", "操作提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { Guid?noticeGuid = gridRow.Cells["colNoticeGuid"].Value.ToGuid(); bool flag = noticeLogic.CancelPurchaseNotice(new ORD_PurchaseNoticeParam() { NoticeGuid = noticeGuid }); if (flag) { BindSuperGrid(); if (RefreshParentForm != null) { RefreshParentForm(); } } } } } } //MessageBox.Show(noticeGuid.ToStringHasNull()); // //SelectedElementCollection col = this.noticedPanel.GetSelectedRows(); // //GridRow row= col[0] as GridRow; }
/// <summary> /// 删 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected override void DelToolStripMenuItem_Click(object sender, EventArgs e) { SelectedElementCollection col = superGridControl1.PrimaryGrid.GetSelectedRows(); if (col.Count <= 0) { MessageBox.Show("请先选择一行!"); return; } if (DialogResult.Yes == MessageBox.Show("确定全部删除吗?删除后将不可恢复!", "WACAT管家", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)) { GridRow row = col[0] as GridRow; string code = row.Cells["gridColumn1"].Value.ToString(); try { int result = otm.DelOrderType(code); if (result > 0) { MessageBox.Show("删除成功!"); BindDGV(); return; } else { MessageBox.Show("删除失败!"); return; } } catch (Exception ex) { MessageBox.Show("删除失败,请检查服务器连接并尝试重新删除.错误:" + ex.Message); } } }
private void btndown_Click(object sender, EventArgs e) { if (supergrid.PrimaryGrid.SelectedRowCount > 0) { if (supergrid.PrimaryGrid.Rows.Count > 1) { SelectedElementCollection items = supergrid.PrimaryGrid.GetSelectedRows(); GridRow rerow = null; foreach (GridRow item in items) { rerow = item; int n = rerow.Index; if (n != supergrid.PrimaryGrid.Rows.Count - 1) { supergrid.PrimaryGrid.Rows.Remove(item); supergrid.PrimaryGrid.Rows.Insert(n + 1, rerow); Image imagetemp = null; imagetemp = imagelist[n]; imagelist[n] = imagelist[n + 1]; imagelist[n + 1] = imagetemp; ISymbol symboltemp = Symbollist[n]; Symbollist[n] = Symbollist[n + 1]; Symbollist[n + 1] = symboltemp; } RePainPictureBox(Radio); } } } }
//编辑 private void ToolStripMenuItemEdit_Click(object sender, EventArgs e) { if (superGridControlClient.GetSelectedRows().Count > 0) { Client client = new Client(); SelectedElementCollection col = superGridControlClient.GetSelectedRows(); if (col.Count > 0) { GridRow gridRow = col[0] as GridRow; client.Cli_ID = Convert.ToInt32(gridRow.Cells["gridColumnID"].Value); client.Cli_Code = gridRow.Cells["gridColumnCode"].Value.ToString(); client.Cli_zhiwen = gridRow.Cells["gridColumnZ"].Value.ToString(); client.Cli_Name = gridRow.Cells["gridColumnCliName"].Value.ToString(); client.Cli_LinkMan = gridRow.Cells["gridColumnMan"].Value.ToString(); client.Cli_Company = gridRow.Cells["gridColumnCo"].Value.ToString(); client.Cli_Phone = gridRow.Cells["gridColumnPho"].Value.ToString(); client.Cli_PhoneTwo = gridRow.Cells["gridColumnPho2"].Value.ToString(); client.Cli_faxes = gridRow.Cells["gridColumnFax"].Value.ToString(); client.Cli_CityCode = gridRow.Cells["gridColumnCiCode"].Value.ToString(); client.Cli_area = gridRow.Cells["gridColumnArea"].Value.ToString(); client.Cli_Address = gridRow.Cells["gridColumnAd"].Value.ToString(); client.Cli_TypeCode = gridRow.Cells["gridColumnTy"].Value.ToString(); client.Cli_TypeName = gridRow.Cells["gridColumnTyName"].Value.ToString(); client.Cli_DiscountCode = gridRow.Cells["gridColumnDiCode"].Value.ToString(); client.Cli_Bankaccounts = gridRow.Cells["gridColumnBa"].Value.ToString(); client.Cli_OpenBank = gridRow.Cells["gridColumnOpB"].Value.ToString(); client.Cli_Olddata = null; client.Cli_Oldreturn = null; client.Cli_Newoutdata = null; client.Cli_Newintodata = null; client.Cli_Createdata = Convert.ToDateTime(gridRow.Cells["gridColumnCre"].Value); client.Cli_Limit = gridRow.Cells["gridColumnLim"].Value.ToString(); client.Cli_RemainLimit = gridRow.Cells["gridColumnReLim"].Value.ToString(); client.Cli_ClearLimitdate = gridRow.Cells["gridColumnDay"].Value.ToString(); client.Cli_ShouldMoney = gridRow.Cells["gridColumnSho"].Value.ToString(); client.Cli_GetMoney = gridRow.Cells["gridColumnGet"].Value.ToString(); client.Cli_PreMoney = gridRow.Cells["gridColumnPre"].Value.ToString(); client.Cli_Remark = gridRow.Cells["gridColumnRem"].Value.ToString(); client.Cli_safetone = gridRow.Cells["gridColumnsafetone"].Value.ToString(); client.Cli_safettwo = gridRow.Cells["gridColumnsafettwo"].Value.ToString(); client.Cli_Enable = Convert.ToInt32(gridRow.Cells["gridColumnEnable"].Value); client.Cli_PicName = gridRow.Cells["gridColumnPic"].Value.ToString(); } CreateClientForm ccf = new CreateClientForm(); ccf.Client = client; ccf.ShowDialog(this); closeDispose(); } else { MessageBox.Show("请选择要修改的行"); } }
/// <summary> /// Handles SuperGrid drag drops /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TreeView1DragDrop(object sender, DragEventArgs e) { TreeView tv = sender as TreeView; if (tv != null) { ClearNodeStyles(tv); Point clientPoint = tv.PointToClient(new Point(e.X, e.Y)); TreeNode node = tv.GetNodeAt(clientPoint.X, clientPoint.Y); if (e.Data.GetDataPresent(typeof(SelectedElementCollection)) == true) { SelectedElementCollection rows = (SelectedElementCollection)e.Data.GetData(typeof(SelectedElementCollection)); if (rows[0] is GridRow) { StringBuilder sb = new StringBuilder(); foreach (GridRow item in rows) { if (node == null) { node = new TreeNode(); tv.Nodes.Add(node); } sb.Length = 0; for (int i = 0; i < item.Cells.Count; i++) { GridCell cell = item.Cells[i]; sb.Append(cell.Value); sb.Append(", "); } sb.Length -= 2; node.Text = sb.ToString(); node.ForeColor = Color.Red; node = node.NextVisibleNode; } } } } }
private void btnOK_Click(object sender, EventArgs e) { //从列表得到FeatureID SelectedElementCollection items = superGridCtl.PrimaryGrid.GetSelectedRows(); if (items.Count > 0) { GridRow row = (GridRow)items[0]; m_nFeatureID = Convert.ToInt32(row.Cells[m_nIDFieldIndex].Value); } if (m_nFeatureID < 0) { MessageBox.Show("请选择一条记录!"); this.DialogResult = DialogResult.None; return; } }
private void EraseText() { GridPanel panel = superGridControl1.PrimaryGrid; SelectedElementCollection items = panel.GetSelectedElements(); List <GridCell> cells = items.GetCells(); foreach (GridCell cell in cells) { if (cell.IsEmptyCell == false) { cell.CellStyles.Default.Font = null; cell.CellStyles.Default.TextColor = Color.Empty; cell.Value = null; } } }
/// <summary> /// Handles SuperGrid drag drop requests /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ListBox1DragDrop(object sender, DragEventArgs e) { ListBox lb = sender as ListBox; if (lb != null) { Point clientPoint = lb.PointToClient(new Point(e.X, e.Y)); int index = lb.IndexFromPoint(clientPoint); if (index >= 0) { if (e.Data.GetDataPresent(typeof(SelectedElementCollection)) == true) { SelectedElementCollection rows = (SelectedElementCollection)e.Data.GetData(typeof(SelectedElementCollection)); if (rows[0] is GridRow) { StringBuilder sb = new StringBuilder(); foreach (GridRow item in rows) { if (index >= lb.Items.Count) { lb.Items.Add(""); } sb.Length = 0; for (int i = 0; i < item.Cells.Count; i++) { GridCell cell = item.Cells[i]; sb.Append(cell.Value); sb.Append(", "); } sb.Length -= 2; lb.Items[index++] = sb.ToString(); } } } } } }
private void btnremove_Click(object sender, EventArgs e) { if (supergrid.PrimaryGrid.Rows.Count > 0) { SelectedElementCollection items = supergrid.PrimaryGrid.GetSelectedRows(); GridRow rurow = null; foreach (GridRow item in items) { rurow = item; int n = rurow.Index; supergrid.PrimaryGrid.Rows.Remove(item); imagelist.Remove(imagelist[n]); Symbollist.Remove(Symbollist[n]); RePainPictureBox(Radio); } } }
/// <summary> /// Handles user requests to fill the selected cells with /// the currently set color picker background color /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CpBackgroundClick(object sender, EventArgs e) { if (CpBackground.SelectedColor.IsEmpty == false) { GridPanel panel = superGridControl1.PrimaryGrid; SelectedElementCollection items = panel.GetSelectedElements(); List <GridCell> cells = items.GetCells(); // The AllocateCells routine allocates all the cells needed // to be able to satisfy the user's request. // // Special care should be taken to understand that the List of cells // returned in the call to items.GetCells is only useful for the // determination of row and column details, and is not valid for any // type of modification. // // After cell allocation has taken place, the grid rows now contain // newly created cells - and it is those cells that need to be referenced // in any future cell operation. AllocateCells(cells); Background background = new Background(CpBackground.SelectedColor); foreach (GridCell cell in cells) { // Make sure we use any newly allocated cell, and not // a potentially Empty cell retrieved in the selection list GridCell ncell = cell.GridRow.Cells[cell.ColumnIndex]; ncell.CellStyles.Default.Background = background; } // Clear all user selections so that the // background change is more apparent to the user. panel.ClearAll(); } }
/// <summary> /// 改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected override void UpdToolStripMenuItem_Click(object sender, EventArgs e) { SelectedElementCollection col = superGridControl1.PrimaryGrid.GetSelectedRows(); if (col.Count <= 0) { MessageBox.Show("请先选择一行!"); return; } GridRow row = col[0] as GridRow; id = row.Cells["gridColumn1"].Value.ToString(); InsOrderTypeNode iotn = new InsOrderTypeNode(); StateType = 1; iotn.ShowDialog(this); if (base.isflag == true) { BindDGV(); } }
/// <summary> /// 改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected override void UpdToolStripMenuItem_Click(object sender, EventArgs e) { SelectedElementCollection col = superGridControl1.PrimaryGrid.GetSelectedRows(); if (col.Count <= 0) { MessageBox.Show("请先选择一行!"); return; } GridRow row = col[0] as GridRow; id = XYEEncoding.strCodeHex(row.Cells[0].Value.ToString()); InsEmpolyee ibn = new InsEmpolyee(); StateType = 1; ibn.ShowDialog(this); if (base.isflag == true) { BindDGV(); } }
/// <summary> /// Handles grid selection changes by updating the /// toolbar textbox if all selected cells have the /// same content value. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void SuperGridControl1SelectionChanged(object sender, GridEventArgs e) { GridPanel panel = superGridControl1.PrimaryGrid; SelectedElementCollection items = panel.GetSelectedElements(); List <GridCell> cells = items.GetCells(); string s = null; if (cells.Count > 0) { foreach (GridCell cell in cells) { if (ValuesMatch(ref s, (string)cell.Value) == false) { break; } } } TbxCellText.Text = s ?? ""; }
/// <summary> /// 改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected override void UpdToolStripMenuItem_Click(object sender, EventArgs e) { SelectedElementCollection col = superGridControl1.PrimaryGrid.GetSelectedRows(); if (col.Count <= 0) { MessageBox.Show("请先选择一行!"); return; } GridRow row = col[0] as GridRow; id = row.Cells[1].Value.ToString(); InsBankAccount iba = new InsBankAccount(); StateType = 1; iba.ShowDialog(this); if (isflag == true) { BindDGV(false); } }
private void SuperGridOperPanel_RowClick(object sender, GridRowClickEventArgs e) { //取得使用者選取的OP名稱 ListSelOper = new List <string>(); SelectedElementCollection OperSelCollection = OperPanel.GetSelectedElements(); foreach (GridRow item in OperSelCollection) { ListSelOper.Add(item.Cells[1].Value.ToString()); //CaxLog.ShowListingWindow(item.Cells[0].Value.ToString());//可以看出debug中item的值會顯示GridRow的型態 } //這邊設定NX中是否顯示加工路徑為->單條顯示or多條顯示 NXOpen.CAM.Preferences preferences1 = theSession.CAMSession.CreateCamPreferences(); if (ListSelOper.Count == 1) { preferences1.ReplayRefreshBeforeEachPath = true; preferences1.Commit(); preferences1.Destroy(); } else if (ListSelOper.Count > 1) { preferences1.ReplayRefreshBeforeEachPath = false; preferences1.Commit(); preferences1.Destroy(); } foreach (string SelectOper in ListSelOper) { for (int i = 0; i < OperationObj.Length; i++) { if (SelectOper == OperationObj[i].Name) { NXOpen.CAM.CAMObject[] tempObjToCreateImg = new CAMObject[1]; tempObjToCreateImg[0] = (NXOpen.CAM.CAMObject)OperationObj[i]; workPart.CAMSetup.ReplayToolPath(tempObjToCreateImg); } } } }
//删除 private void ToolStripMenuItemDelete_Click(object sender, EventArgs e) { if (superGridControlMaterial.GetSelectedRows().Count > 0) { if (DialogResult.No == MessageBox.Show("确认要删除选中行的数据吗?", "请注意", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2)) { return; } Client client = new Client(); ClientManager cm = new ClientManager(); SelectedElementCollection col = superGridControlMaterial.GetSelectedRows(); if (col.Count > 0) { GridRow gridRow = col[0] as GridRow; try { bool result = cm.DeleteFake(gridRow.Cells[1].Value.ToString()); if (result) { MessageBox.Show("删除成功!"); isflag = true; closeDispose(); } else { MessageBox.Show("删除失败,请检查是否选中指定行"); } } catch (Exception ex) { MessageBox.Show("删除异常,请检查服务器连接:" + ex.Message); } } } else { MessageBox.Show("请先选中要进行删除的行"); } }
protected virtual List <int> GetSelectRows() { var ids = new List <int>(); //获取选中单元整行数据 SelectedElementCollection selectedRows = this.superGrid.PrimaryGrid.GetSelectedRows(); foreach (var selectedRow in selectedRows) { try { GridRow gridRow = selectedRow as GridRow; var id = gridRow.Cells["Id"].Value; this.Id = Convert.ToInt32(id); ids.Add(Id); } catch (Exception ex) { throw new Exception("没有绑定Id,主键列,请修改" + ex.ToString()); } } return(ids); }
/// <summary> /// 操作-修改信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void UpdToolStripMenuItem_Click(object sender, EventArgs e) { SelectedElementCollection col = superGridControl1.PrimaryGrid.GetSelectedRows(); if (col.Count > 0) { GridRow row = col[0] as GridRow; code = row.Cells["gridColumn1"].Value.ToString(); stats = 1; //0为新增 1为修改 InsSupplier inssupplier = new InsSupplier(); inssupplier.ShowDialog(this); if (isflag) { if (treeView1.SelectedNode == null || treeView1.SelectedNode.Text == "所有地区") { BindSupGrid(); } else { name = treeView1.SelectedNode.Text.ToString(); try { string cityName = treeView1.SelectedNode.Text.ToString(); superGridControl1.PrimaryGrid.DataSource = sm.SelSupplierByCityCode(cityName); } catch (Exception ex) { MessageBox.Show("保存失败,请检查服务器连接并尝试重新保存.错误:" + ex.Message); } } } } else { MessageBox.Show("请先选择一行!"); return; } }
/// <summary> /// 编辑按钮 获取用户选定的行 若行大于0则创建实体传递给创建窗体 填充创建窗体的 /// 文本编辑控件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 编辑ToolStripMenuItem_Click(object sender, EventArgs e) { if (superGridControl1.PrimaryGrid.GetSelectedRows() != null) { SelectedElementCollection col = superGridControl1.PrimaryGrid.GetSelectedRows(); if (col.Count > 0) { GridRow row = col[0] as GridRow; CreateClientTypeForm.formType ft = new CreateClientTypeForm.formType(); ft.formStatic = "改"; ft.formText = "修改类别"; ft.richTextbox = row.Cells[2].Value == null ? "" : row.Cells[2].Value.ToString(); ft.textboxName = row.Cells[3].Value == null ? "" : row.Cells[3].Value.ToString(); CreateClientTypeForm cltf = new CreateClientTypeForm(ft); cltf.ShowDialog(); if (refresh) { loadData(); refresh = false; } } else { MessageBox.Show("请先选中要修改的数据所在行"); } } else { MessageBox.Show("请先选中要修改的数据所在行"); } }
private void 编辑ToolStripMenuItem_Click(object sender, EventArgs e) { if (superGridControl1.GetSelectedRows().Count > 0) { Model.Department dep = new Model.Department(); SelectedElementCollection col = superGridControl1.GetSelectedRows(); if (col.Count > 0) { GridRow gridRow = col[0] as GridRow; dep.Dt_Code = gridRow["gridColumn2"].Value.ToString(); dep.Dt_Name = gridRow["gridColumn4"].Value.ToString(); dep.Dt_RoleCode = gridRow["gridColumn3"].Value.ToString(); } InDepartment updatedep = new InDepartment(); updatedep._update = true; updatedep._Department = dep; updatedep.ShowDialog(this); } else { MessageBox.Show("请先选择需要编辑的信息"); } }
private void GetSelectedCells(GridContainer container, SelectedElementCollection items) { foreach (GridElement item in container.Rows) { if (item.Visible == true) { GridContainer citem = item as GridContainer; if (citem != null) { GridPanel panel = citem as GridPanel; if (panel != null) { if (panel.VirtualMode == false) panel.GetSelectedCells(items); } if (citem.Rows.Count > 0) GetSelectedCells(citem, items); } } } }
///<summary> /// GetSelectedCells ///</summary> public SelectedElementCollection GetSelectedCells() { GridPanel panel = GridPanel; if (panel != null) { SelectedElementCollection cells = new SelectedElementCollection(SelectedCells.Count); panel.GetSelectedCells(cells, this); return (cells); } return (null); }
//编辑 private void ToolStripMenuItemEdit_Click(object sender, EventArgs e) { if (superGridControlMaterial.GetSelectedRows().Count > 0) { Model.Material material = new Model.Material(); SelectedElementCollection col = superGridControlMaterial.GetSelectedRows(); if (col.Count > 0) { GridRow gridRow = col[0] as GridRow; material.Ma_Barcode = gridRow.Cells["Ma_Barcode"].Value.ToString(); material.Ma_Clear = 1; material.Ma_Code = gridRow.Cells["Ma_Code"].Value.ToString(); if (gridRow.Cells["Ma_CreateDate"].Value == null || gridRow.Cells["Ma_InDate"].Value == DBNull.Value) { material.Ma_CreateDate = null; } else { material.Ma_CreateDate = Convert. ToDateTime(gridRow.Cells["Ma_CreateDate"].Value); } material.Ma_Enable = Convert.ToInt32(gridRow.Cells["Ma_Enable"].Value); material.Ma_ID = Convert.ToInt32(gridRow.Cells["Ma_ID"].Value); if (gridRow.Cells["Ma_InDate"].Value == null || gridRow.Cells["Ma_InDate"].Value == DBNull.Value) { material.Ma_InDate = null; } else { material.Ma_InDate = Convert.ToDateTime(gridRow.Cells["Ma_InDate"].Value); } material.Ma_InPrice = gridRow.Cells["Ma_InPrice"].Value.ToString(); material.Ma_Model = gridRow.Cells["Ma_Model"].Value.ToString(); material.Ma_Name = gridRow.Cells["Ma_Name"].Value.ToString(); material.Ma_PicName = gridRow.Cells["Ma_PicName"].Value.ToString(); material.Ma_Price = gridRow.Cells["Ma_Price"].Value.ToString(); material.Ma_PriceA = gridRow.Cells["Ma_PriceA"].Value.ToString(); material.Ma_PriceB = gridRow.Cells["Ma_PriceB"].Value.ToString(); material.Ma_PriceC = gridRow.Cells["Ma_PriceC"].Value.ToString(); material.Ma_PriceD = gridRow.Cells["Ma_PriceD"].Value.ToString(); material.Ma_PriceE = ""; material.Ma_Remark = gridRow.Cells["Ma_Remark"].Value.ToString(); material.Ma_RFID = gridRow.Cells["Ma_RFID"].Value.ToString(); material.Ma_Safetytwo = ""; material.Ma_Safeyone = ""; material.Ma_SupID = gridRow.Cells["Ma_SupID"].Value.ToString(); material.Ma_Supplier = gridRow.Cells["Ma_Supplier"].Value.ToString(); material.Ma_TypeID = gridRow.Cells["Ma_TypeID"].Value.ToString(); material.Ma_TypeName = gridRow.Cells["Ma_TypeName"].Value.ToString(); material.Ma_Unit = gridRow.Cells["Ma_Unit"].Value.ToString(); material.Ma_zhujima = gridRow.Cells["Ma_zhujima"].Value.ToString(); } MaterialCreateForm mcf = new MaterialCreateForm(); mcf.Material = material; mcf.ShowDialog(this); closeDispose(); } else { MessageBox.Show("请选择要修改的行"); } }
/// <summary> /// Handles SuperGrid DragDrop events /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SuperGridControlDragDrop(object sender, DragEventArgs e) { SuperGridControl sg = sender as SuperGridControl; if (sg != null) { ClearStyles(sg); Point pt = sg.PointToClient(new Point(e.X, e.Y)); GridElement item = sg.GetElementAt(pt.X, pt.Y); // If the data we are dropping is from a SuperGrid, then // be a little bit more discerning about how we drop it if (_SrcGrid != null) { SelectedElementCollection items = (SelectedElementCollection)e.Data.GetData(typeof(SelectedElementCollection)); if (item is GridCell) { if (_SrcElement is GridRow) { DropSgRow(e, ((GridCell)item).GridRow, items); } else { DropSgCell((GridCell)item, items); } } else if (item is GridRow) { DropSgRow(e, (GridRow)item, items); } else if (item is GridColumnHeader) { DropSgColumnHeader((GridColumnHeader)item, items, pt); } else if (item is GridPanel) { DropSgPanel((GridPanel)item, items); } } else { if (item is GridCell) { if (_SrcElement is GridRow) { DropRow(e, ((GridCell)item).GridRow); } else { DropCell(e, (GridCell)item); } } else if (item is GridRow) { DropRow(e, (GridRow)item); } else if (item is GridColumnHeader) { DropColumnHeader(e, (GridColumnHeader)item, pt); } } ClearDragHighlight(); } }