6. Label LinkLabel - sandeulsandeul/let-s-learning-C-winForm- GitHub Wiki
Label
winForm ์ ๊ธ์ ๋์ธ ์ ์๋ ๊ธฐ๋ฅ์ผ๋ก default ๊ฐ Autosize ๊ฐ์ด true ์ธ ๊ฒ์ธ๋ฐ, ์ด ์ํ๋ ๋ฌธ์์ด์ด ์ ๋ ฅ๋ ๋งํผ ๊ธธ์ด์ง๋ ๊ฒ์ด๋ค.
๋ฌธ์ ๋ ํผ ๋ฐ์ผ๋ก ๋๊ฐ๊ฒ ๋๋ฉด ์๋ฆฐ๋ค๋ ๊ฒ์ธ๋ฐ, ์ด ๊ฒฝ์ฐ Autosize๋ฅผ false๋ก ๋ฐ๊พธ๊ณ Label์ ํฌ๊ธฐ์์ ์ธ๋ก๋ก ๋๋ ค์ฃผ๋ฉด ์๋์ผ๋ก Multi-Line ์ฒ๋ผ ์ฌ์ฉ์ด ๊ฐ๋ฅํ๋ค.
linkLabel
Label๊ณผ ์ ์ฌํ๋ ๋งํฌ๋ฅผ ํด๋ฆญํ๋ฉด ์๋ก์ด ์ธํฐ๋ท ์ฐฝ์ ๋์ฐ๊ฑฐ๋ ๋ฉ์ธ์ง ๋ฐ์ค๋ฅผ ๋์ธ ์ ์๋ค. Process.start();๋ฅผ ์ฌ์ฉํ๊ธฐ ์ํด์๋ using System.Diagnostics;๊ฐ ๊ผญ ํ์ํ๋ค.
`namespace WindowsFormsApp2 { public partial class Form1 : Form {
public Form1()
{
InitializeComponent();
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("https://www.naver.com/");
}
private void label1_Click(object sender, EventArgs e)
{
label1.BackColor = (label1.BackColor == Color.Blue) ?
Color.Azure : Color.Blue;
}
}
}`