dc22wt 你好,
1.如果想设置表单没有任何单元格被选中,那么只能使用 2# 中的方法,
2.获取用户选择行的索引,可以通过 CellClick 事件获取,
实现代码如下:- int selectRowIndex = -1;
- private void button1_Click(object sender, EventArgs e)
- {
- this.fpSpread1.Sheets[0].DataSource = test;
- this.fpSpread1.Sheets[0].AddUnboundRows(0, 1);
- for (int i = 1; i < this.fpSpread1.Sheets[0].RowCount; i++)
- {
- this.fpSpread1.Sheets[0].RowHeader.Cells[i, 0].Text = i.ToString();
- }
- this.fpSpread1.Sheets[0].Rows[0].Visible = false;
- this.fpSpread1.Sheets[0].SetActiveCell(0, 0);
- }
- private void fpSpread1_CellClick(object sender, FarPoint.Win.Spread.CellClickEventArgs e)
- {
- selectRowIndex = e.Row-1;
- }
复制代码 |