DataGridViewLinkColumn
에는 표시 텍스트와 URL을 구분하는 직접적인 속성이 없습니다.
목표를 달성하려면 CellFormatting
과 CellContentClick
의 두 가지 이벤트를 처리해야합니다. 이 이벤트들을 구독하십시오.
CellFormatting
이벤트 처리기에서 서식이 지정된 값을 Click here to visit
으로 변경하십시오. FormattingApplied
플래그는 True
으로 설정해야합니다. 이렇게하면 값의 형식을 더 이상 지정할 수 없기 때문입니다.
Private Sub dataGridView1_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs)
If e.ColumnIndex = 'link column index Then
e.Value = "Click here to visit";
e.FormattingApplied = True;
End If
End Sub
는
Process
클래스를 사용, 기본 브라우저에서 링크를 열고
Start
메소드에 인자로 URL을 전달합니다. 코드를
CellContentClick
이벤트 처리기에 넣습니다.
Private Sub dataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs)
If e.ColumnIndex = 'link column index Then
Process.Start(dataGridView1(e.ColumnIndex, e.RowIndex).Value.ToString());
End If
End Sub
고마워요. :) –
@ MetinÇetin, 도와 줘서 다행 :) – Junaith