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;
    }
}

}`