不好意思,上面描述有些不清楚。以下是我的代码:
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- grid.AllowMerging = AllowMergingEnum.FixedOnly
- grid.Cols(1).AllowMerging = True
- grid.Cols(1).TextAlignFixed = TextAlignEnum.CenterCenter
- grid.Cols(2).AllowMerging = True
- grid.Cols(2).TextAlignFixed = TextAlignEnum.CenterCenter
- grid.SetData(0, 1, "出席" & vbCrLf & "番号")
- grid.SetData(1, 1, "出席" & vbCrLf & "番号")
- Dim rng As CellRange = grid.GetCellRange(0, 2, 1, 2)
- rng.Data = " "
- End Sub
复制代码
主要是用CellRange的方法给另一列的列头赋了半角空格,导致点击列头排序,或者Cell内容编辑,改变列宽时,就会引起列头居中表示错误。 |