//修改仓库 private void EditWareHouse_Click(object sender, EventArgs e) { try { MessageBox.Show(gridView1.FocusedRowHandle.ToString()); //获取到的焦点总为负数 } catch (Exception ex) { MessageBox.Show(ex.Message); } }
解决方案
40
dataGridView1.CurrentRow.Index;本人一般用这个获取选中行
20
大的负数值,是预定义行
// 摘要: // The grid control. [ComplexBindingProperties("DataSource", "DataMember")] [DataAccessMetadata("All", SupportedProcessingModes = "All")] [Description("A data-aware control that displays data in one of several views, enables editing data, provides data filtering, sorting, grouping and summary calculation features.")] [Designer("DevExpress.XtraGrid.Design.GridControlDesigner, DevExpress.XtraGrid.v14.2.Design", typeof(IDesigner))] [Docking(DockingBehavior.Ask)] [DXToolboxItem(true)] [LicenseProvider(typeof(DXWinLicenseProvider))] [ToolboxTabName("DX.14.2: Data & Analytics")] public class GridControl : EditorContainer, IPrintableEx, IPrintable, IBasePrintable, IPrintHeaderFooter, INavigatableControl, IToolTipControlClient, ISupportLookAndFeel, IDXManagerPopupMenu, IViewController, IFilteredComponent, IFilteredComponentBase, IBoundControl, ISupportXtraSerializer, IGestureClient, IGuideDescription, IFilteredComponentColumnsClient, ISearchControlClient, IFilteredComponentColumns, ILogicalOwner { // 摘要: // Contains a value which represents the handle of the Auto Filter Row. For // more information on row handles refer to the Identifying Rows and Cards section. // // 返回结果: // $ public const int AutoFilterRowHandle = -2147483646; // // 摘要: // Contains the value representing the invalid row handle. This value is returned // when an attempt to obtain a particular row fails, etc. Please refer to the // Identifying Rows and Cards topic for more information regarding row handles. // // 返回结果: // $ public const int InvalidRowHandle = -2147483648; // // 摘要: // Contains a value which represents the handle of the New Item Row/Card. For // more information on row handles refer to the Identifying Rows and Cards section. // // 返回结果: // $ public const int NewItemRowHandle = -2147483647; // 摘要: // Creates a new DevExpress.XtraGrid.GridControl control. public GridControl();