LinkLabel
을 사용 중이고 테두리를 빨간색으로 설정하려고합니다. BorderStyle
을 FixedSingle
으로 설정하고 ForeColor
을 빨간색으로 설정했지만 텍스트 만 빨간색이므로 테두리는 여전히 검정입니다.LinkLabel 테두리 색
Label
컨트롤에 대해 동일한 작업을 수행하면 테두리와 텍스트가 빨간색으로 표시됩니다. 제안 사항은 무엇입니까?
LinkLabel
을 사용 중이고 테두리를 빨간색으로 설정하려고합니다. BorderStyle
을 FixedSingle
으로 설정하고 ForeColor
을 빨간색으로 설정했지만 텍스트 만 빨간색이므로 테두리는 여전히 검정입니다.LinkLabel 테두리 색
Label
컨트롤에 대해 동일한 작업을 수행하면 테두리와 텍스트가 빨간색으로 표시됩니다. 제안 사항은 무엇입니까?
BorderStyle
을 None
으로 설정하고 나만의 그림을 그립니다.
private void linkLabel1_Paint(object sender, PaintEventArgs e)
{
if (linkLabel1.ForeColor == Color.Red)
ControlPaint.DrawBorder(e.Graphics, linkLabel1.DisplayRectangle, linkLabel1.ForeColor, ButtonBorderStyle.Solid);
else
ControlPaint.DrawBorder(e.Graphics, linkLabel1.DisplayRectangle, Color.Black, ButtonBorderStyle.Solid);
}
LinkLabels에는 테두리 색 속성이 없지만 OnPaint 이벤트에 연결하여 테두리를 그릴 수 있습니다. windows-tech.info에서이를 수행하는 방법을 보여주는 코드가 있습니다.
LinkLabel 컨트롤에서 새 컨트롤을 파생시킬 수 있습니다. 다시 사용할 계획이라면 LinkLabel 컨트롤에서 새 컨트롤을 파생시킬 수 있습니다. 이 시점에서 "CustomBorderColor"속성을 추가하여 사용할 수도 있습니다. 설정되지 않은 색상이 Empty로 나타나므로 기본값이 투명하게 설정된 색상을 사용합니다. 좋아요 :
using System.Drawing.Color;
private Color m_CustomBorderColor = Color.Transparent;
public Color CustomBorderColor
{
get { return m_CustomBorderColor; }
set { m_CustomBorderColor = value; }
}