MultiRow没有简单的属性来设置所有Cell的宽度随着整个控件来平分的功能。
解决这个问题需要写一些代码自己实现。
给你一个思路:
在MultiRow的SizeChanged事件里通过GcMultiRow的ClientRectangle.Width属性和GcMultiRow的SectionWidth活动Row的宽度。计算出差值。通过Cell上的HorizontalResize方法让所有CellRezise,达到平分的效果。- Private Sub gcMultiRow_SizeChanged(sender As Object, e As EventArgs)
- Dim sizeDiff As Integer = Me.gcMultiRow.ClientRectangle.Width - Me.gcMultiRow.SectionWidth - SystemInformation.VerticalScrollBarWidth
- Dim everyDiff As Integer = sizeDiff / Me.gcMultiRow.ColumnHeaders(0).Cells.Count
- For i As Integer = 0 To Me.gcMultiRow.ColumnHeaders(0).Cells.Count - 1
- Me.gcMultiRow.ColumnHeaders(0).Cells(i).HorizontalResize(everyDiff)
- Next
- End Sub
复制代码 |