나는 다음과 같이 TableLayoutPanel/정의 구성 확장하는 클래스를 가지고 :TableLayoutPanel 테두리 없음 첫 번째 열 주위에?
(한 위의 CellBorderStyle을 설정하는 코드를 주어진 기대하는 것처럼) 내 테이블은 모든 5 열 주위에 테두리를 가지고 그려public class MyTableLayout : TableLayoutPanel
{
public MyTableLayout()
{
this.ColumnCount = 5;
this.RowCount = 1;
this.CellBorderStyle = TableLayoutPanelCellBorderStyle.Outset;
}
}
.
테두리가 첫 번째 열 주위로 그려지는 것을 방지 할 수있는 방법이 있습니까?
나는 당신이 CellPaint 콜백 추가 할 수 있습니다 알고
this.CellPaint += tableLayoutPanel_CellPaint;
을이 콜백에서 당신은 특정 컬럼의 테두리 색상을 변경 같은 것을 수행 할 수 있습니다
private void tableLayoutPanel_CellPaint(object sender, TableLayoutCellPaintEventArgs e)
{
if (e.Column == 0 && e.Row == 0)
{
e.Graphics.DrawRectangle(new Pen(Color.Red), e.CellBounds);
}
}
을하지만 어떻게해야 "No"사각형을 그립니다.
나는 Color.Empty에 색상을 설정하려하지만 그건 작동하지 않았다 :e.Graphics.DrawRectangle(new Pen(Color.Empty), e.CellBounds);
좋은 아이디어 덕분에! –
국경 그리기가'OnPaintBackground'에서 행해지므로 작동하지 않습니다. – Tergiver
@JanTacci 잘게 잘리는 가장자리의 문제를 복제 할 수 없습니다. 'e.CellBounds'를 사용하는 대신'new Rectangle (Point.Empty, new Size (e.CellBounds.Width - 1, e.CellBounds.Height - 1))'을 시도해보십시오. – LarsTech