【WinForms】表格样式复制和表格外框线问题
1、我想把如下图1中的表格样式进行复制一份到后面的行,如何操作;
2、上图1中的外边框线(加粗的黑色线)、而里面的内框线呈黑色(未加粗),请问如何实现; 回复 1楼c519299013的帖子
1.Row下面会暴露Border,CellType属性存储相关信息。可以获取然后设置给需要的行。
2.你是想实现一个外边线粗,内边线细的边框效果么?
通过代码的话,可以设置每个单元格的border,然后设置Spread的BorderCollapse为Collapse。
设计器可以通过Borders->AllBorder来实现。 回复 2楼Alice的帖子
第2个问题,我想要实现外边线粗,内边线细的边框效果,根据你说的我没有实现那种效果,我说一下我做的步骤:
1、我先设置5行5列的的单元格的border为粗线框的格式
2、设置Spread的BorderCollapse为Collapse,最后出来的效果是所有的线条都是粗线框; 回复 3楼c519299013的帖子
用Spread设计器的步骤:
1.Spread的BorderCollapse为Collapse。
2.选择5行5列的单元格,打开Border下拉框,设置All Borders。
3.然后选择Thick Box Border。
这个时候是外边粗,里面细。 我需要用代码实现。我搜索答案的时候发现了如下代码,现在Spread版本把BorderSizeBottom,BorderSizeLeft , BorderSizeRight ,BorderSizeTop ,这些属性应该是设置边框线的粗细:
private void SetBord(int border)
{
for (int i = 0; i < FpSpread1.Rows.Count; i++)
{
for (int j = 0; j < FpSpread1.Columns.Count; j++)
{
this.FpSpread1.Cells.Border.BorderSizeBottom = 1;
this.FpSpread1.Cells.Border.BorderSizeLeft = 1;
this.FpSpread1.Cells.Border.BorderSizeRight = 1;
this.FpSpread1.Cells.Border.BorderSizeTop = 1;
}
}
} 回复 5楼c519299013的帖子
谢谢反馈。
提供反馈解决方案,我们都有金币奖励。
请问这段代码可以满足你的需求么?
还有什么需要跟进的地方?
为了表示感谢,给您分发 100 金币。可以用于兑换论坛奖品。金币规则:点击进入礼品列表:点击进入 回复 6楼Alice的帖子
我现在用的版本不支持
现在的效果还是这样,外面的线没粗,里面的线倒是合并变粗了,请问如何解决? 回复 7楼c519299013的帖子
按照我之前给出的设计器的设计方案,相关的代码如下:
就是将BorderCollapse设置为Collapse,然后设置相关的边框。
你可以根据业务需求将这段代码抽成方法。
private void Form1_Load(object sender, EventArgs e)
{
this.fpSpread1.BorderCollapse = FarPoint.Win.Spread.BorderCollapse.Collapse;
FarPoint.Win.ComplexBorder complexBorder1 = new FarPoint.Win.ComplexBorder(new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.ThickLine), new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.ThickLine), new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.ThinLine), new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.ThinLine));
FarPoint.Win.ComplexBorder complexBorder2 = new FarPoint.Win.ComplexBorder(new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.ThinLine), new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.ThickLine), new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.ThickLine), new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.ThinLine));
FarPoint.Win.ComplexBorder complexBorder3 = new FarPoint.Win.ComplexBorder(new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.ThickLine), new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.ThinLine), new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.ThinLine), new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.ThinLine));
FarPoint.Win.ComplexBorder complexBorder4 = new FarPoint.Win.ComplexBorder(new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.ThinLine), new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.ThinLine), new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.ThickLine), new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.ThinLine));
FarPoint.Win.ComplexBorder complexBorder5 = new FarPoint.Win.ComplexBorder(new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.ThickLine), new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.ThinLine), new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.ThinLine), new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.ThickLine));
FarPoint.Win.ComplexBorder complexBorder6 = new FarPoint.Win.ComplexBorder(new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.ThinLine), new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.ThinLine), new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.ThickLine), new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.ThickLine));
this.fpSpread1_Sheet1.Cells.Get(3, 1).Border = complexBorder1;
this.fpSpread1_Sheet1.Cells.Get(3, 2).Border = complexBorder2;
this.fpSpread1_Sheet1.Cells.Get(4, 1).Border = complexBorder3;
this.fpSpread1_Sheet1.Cells.Get(4, 2).Border = complexBorder4;
this.fpSpread1_Sheet1.Cells.Get(5, 1).Border = complexBorder5;
this.fpSpread1_Sheet1.Cells.Get(5, 2).Border = complexBorder6;
}
外边框线的问题已经解决,内边框线还是有重合问题,线宽为1的时候不会出现! 回复 9楼c519299013的帖子
请问你最后采用的是7楼还是8楼的方法设置边框的?