Skip to content

6. Label LinkLabel

sandeulsandeul edited this page May 11, 2020 · 2 revisions

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

}`

Clone this wiki locally