-
private void _flex_MouseMove(object sender, System.Windows.Input.MouseEventArgs e) { int row, col; double rowHeight, colWidth; row = -1; col = -1; rowHeight = 0; colWidth = 0; Point p = e.GetPosition(_flex); for (int r = 0; r < _flex.Rows.Count; r++) { rowHeight += _flex.Rows[r].ActualHeight; if (p.Y < rowHeight) { row = r; break; } } colWidth = _flex.RowHeaders.DesiredSize.Width; for (int c = 0; c < _flex.Rows.Count; c++) { colWidth += _flex.Columns[c].ActualWidth; if (p.X < colWidth) { col = c; break; } } this.label1.Content = string.Format("({0},{1})", row, col); } 复制代码
鼠标在FlexGrid中移动过程中,我们可以在MouseMove中计算出鼠标所在的行、列值:
关于葡萄城
赋能开发者!葡萄城是专业的集开发工具、商业智能解决方案、低代码开发平台于一身的软件和服务提供商,为超过 75% 的全球财富 500 强企业提供服务。葡萄城专注控件软件领域30年,希望通过模块化的开发控件、灵活的低代码应用开发平台等一系列开发工具、解决方案和服务,帮助开发者快速响应复杂多变的业务需求,最大程度地发挥开发者的才智和潜能,让开发者的 IT 人生更从容更美好。
了解详情,请访问葡萄城官网。