回复 5楼lud的帖子
以下代码演示了:
1、如果只改变第一列的宽度,可以任意进行修改
2、如果同时改变多列时,其中包含第一列,此时第一列宽度不变
- private float ColBWidth = 80;
- private void Form1_Load(object sender, EventArgs e)
- {
- fpSpread1.Sheets[0].Columns[1].Width = ColBWidth;
- }
- private void fpSpread1_ColumnWidthChanged(object sender, FarPoint.Win.Spread.ColumnWidthChangedEventArgs e)
- {
- FarPoint.Win.Spread.ColumnWidthChangeExtents arg;
- for (int i = 0; i < e.ColumnList.Count; i++)
- {
- arg = (e.ColumnList[i] as FarPoint.Win.Spread.ColumnWidthChangeExtents);
-
- // 如果第1列包含其中,就将第1列的宽度设置为固定值
- if ((arg.FirstColumn <= 1 && arg.LastColumn >= 1) && (arg.LastColumn - arg.FirstColumn >0))
- {
- fpSpread1.ActiveSheet.Columns[1].Width = ColBWidth;
- }
- }
- ColBWidth = fpSpread1.Sheets[0].Columns[1].Width;
- }
复制代码 |