C# Winform | TabControl / Modern Design UI - #2
C# Winform | TabControl / Modern Design UI - #1
위 링크에서 Component 작업을 완료하신 후에 진행하세요.
Form Load Event
전역 변수 선언과 TebControl Page 지정
// 전역변수
private List<Label> menws;
private List<Color> menw_colors;
//Form - Load Event
private void TabTest_Load(object sender, EventArgs e)
{
menws = new List<Label>();
menws.Add(btn_Menu1);
menws.Add(btn_Menu2);
menws.Add(btn_Menu3);
menw_colors = new List<Color>();
menw_colors.Add(Color.FromArgb(53, 124, 225));
menw_colors.Add(Color.DarkOrange);
menw_colors.Add(Color.FromArgb(177, 70, 194));
//시작 TabPage 설정
Tab_Main.SelectedIndex = 0;
}
|
cs |
Menu Click Event
같은 TabPage가 아니면 지정한 Color로 해당 Menu의 색을 변경하고 Bar를 이동시킨다.
private void setMenuChgane(int index)
{
if (Tab_Main.SelectedIndex != index)
{
menws[Tab_Main.SelectedIndex].ForeColor = Color.FromArgb(111, 111, 111);
menws[index].ForeColor = menw_colors[index];
Tab_Menu_Select_Bar.BackColor = menw_colors[index];
Tab_Menu_Select_Bar.Location = new Point(menws[index].Location.X, 0);
Tab_Main.SelectedIndex = index;
}
}
private void btn_Menu1_Click(object sender, EventArgs e)
{
setMenuChgane(0);
}
private void btn_Menu2_Click(object sender, EventArgs e)
{
setMenuChgane(1);
}
private void btn_Menu3_Click(object sender, EventArgs e)
{
setMenuChgane(2);
}
|
cs |
'C# Winform' 카테고리의 다른 글
C# Winform | Watermark in a textbox | Placeholder | custom control (0) | 2020.11.25 |
---|---|
C# Winform | remove zero from decimal c# (0) | 2020.11.16 |
C# Winform | TabControl / Modern Design UI - #1 (2) | 2020.11.02 |
C# Winform | string NewLine 줄바꿈 (0) | 2020.10.28 |
C# Winform | WebView / Tradingview - Chart (widget) (0) | 2020.10.16 |