我上传了一个视频。另外
private void InitFp()
{
Hsp.Core.NetFrame.UI.Utils.FpUtils.FarPointStyle(this.fpUserRoleManage);
this.fpUserRoleManage_Sheet1.ColumnHeader.Rows[0].Height = 30F;
this.fpUserRoleManage_Sheet1.Rows.Default.Height = 25;
this.fpUserRoleManage_Sheet1.Rows.Default.VerticalAlignment = CellVerticalAlignment.Center;
this.fpUserRoleManage_Sheet1.ColumnHeader.Rows[0].Font = new Font("微软雅黑", 13.5F, FontStyle.Bold);
this.fpUserRoleManage_Sheet1.OperationMode = OperationMode.Normal;
this.fpUserRoleManage_Sheet1.ColumnHeader.Rows.Get(0).Height = 40F;
this.fpUserRoleManage_Sheet1.ColumnHeader.Cells[0, 0].CellType = new FarPoint.Win.Spread.CellType.CheckBoxCellType();
this.fpUserRoleManage_Sheet1.Columns[1].BackColor = Color.AliceBlue;
this.fpUserRoleManage_Sheet1.Columns[2].BackColor = Color.AliceBlue;
this.fpUserRoleManage_Sheet1.Columns[3].BackColor = Color.AliceBlue;
this.fpUserRoleManage_Sheet1.Columns[4].BackColor = Color.AliceBlue;
}
private void InitEvent()
{ fpUserRoleManage.CellClick += FpUserRoleManageCellClick;
}
private void FpUserRoleManageCellClick(object sender, CellClickEventArgs e)
{
if (e.ColumnHeader && e.Column == 0)
{
bool chk = false;
if (this.fpUserRoleManage_Sheet1.ColumnHeader.Cells[0, 0].Value != null)
{
bool.TryParse(this.fpUserRoleManage_Sheet1.ColumnHeader.Cells[0, 0].Value.ToString(), out chk);
}
this.fpUserRoleManage_Sheet1.ColumnHeader.Cells[0, 0].Value = !chk;
for (int i = 0; i < fpUserRoleManage_Sheet1.RowCount; i++)
{
if (this.fpUserRoleManage_Sheet1.Cells[i, 1].Value == null)
{
break;
}
this.fpUserRoleManage_Sheet1.Cells[i, 0].Value = !chk;
}
}
else if (!e.ColumnHeader && e.Column == 0)
{
bool allRowsChecked = true;
int checkedRowCount = 0; // 记录已勾选的行数
for (int i = 0; i < fpUserRoleManage_Sheet1.RowCount; i++)
{
if (this.fpUserRoleManage_Sheet1.Cells[i, 0].Value == null)
{
break;
}
if (Convert.ToBoolean(this.fpUserRoleManage_Sheet1.Cells[i, 0].Value))
{
checkedRowCount++;
}
else
{
allRowsChecked = false;
}
}
// 更新列头复选框的状态
this.fpUserRoleManage_Sheet1.ColumnHeader.Cells[0, 0].Value = checkedRowCount == fpUserRoleManage_Sheet1.RowCount;
}
}
这是我事件的Demo。
|
|