您好,
看了您的帖子,似乎您希望点击在列头第一行的某个cell(该cell可能是在一个合并cell中)上,但是其正下方的某一列被选中?
请试一试下面的代码,看是否是您需要的效果:
public Form1()
{
InitializeComponent();
this.fpSpread1.ActiveSheet.ColumnHeaderRowCount = 3;
this.fpSpread1.ActiveSheet.ColumnHeader.Cells[0, 0].ColumnSpan = 4;
this.fpSpread1.ActiveSheet.ColumnHeader.Cells[1, 5].ColumnSpan = 6;
this.fpSpread1.CellClick += fpSpread1_CellClick;
}
void fpSpread1_CellClick(object sender, FarPoint.Win.Spread.CellClickEventArgs e)
{
HitTestInformation hitInfo = fpSpread1.HitTest(e.X, e.Y);
if (hitInfo.Type == HitTestType.ColumnHeader)
{
CellRange cellRange = this.fpSpread1.GetCellFromPixel(0, 0, e.X, e.Y + 100);
this.fpSpread1.ActiveSheet.AddSelection(-1, cellRange.Column, -1, 1);
e.Cancel = true;
}
} |