728x90
반응형
winform에 panel 하나를 추가 후 그라데이션 색상을 줘보겠다.

LinearGradientBrush 라는 것을 사용하면 되는데, 이걸 사용하려면 일단 using System.Drawing.Drawing2D; 을 추가해줘야 한다.
1. using 추가
using System.Drawing.Drawing2D;
2. 윈폼에 panel 추가 후 paint 이벤트 함수 추가

3. 함수 작성
private void panel1_Paint(object sender, PaintEventArgs e)
{
Color firstColor = System.Drawing.ColorTranslator.FromHtml("#fbc2eb");
Color SecontColor = System.Drawing.ColorTranslator.FromHtml("#a6c1ee");
LinearGradientBrush br = new LinearGradientBrush(this.ClientRectangle, firstColor, SecontColor, 45, false);
e.Graphics.FillRectangle(br, this.ClientRectangle);
}
LinearGradientBrush에 마우스를 올려보면
사각형, 시작 색, 끝 색, 방향등을 주라는 것을 확인할 수 있다.

그라데이션 조합은 하기 사이트를 참조했다.
Free Gradients Collection by itmeo.com
Free collection of 180 background gradients that you can use as content backdrops in any part of your website.
webgradients.com
Srart Color, EndColor 설정 후 각도는 45도로 주었다.

728x90
반응형
'c# > Winform' 카테고리의 다른 글
[c#] combobox DropDown, 열고 닫을 때 이벤트, 사이즈 변경 (0) | 2022.01.28 |
---|---|
[c#] winform Datetimepicker (0) | 2021.12.21 |
[c#] winform progressbar (0) | 2021.12.21 |
[c#] winform 버튼 못누르게 enable (0) | 2021.12.16 |
[c#] winform txt File 쓰기 (0) | 2021.12.15 |