2013-02-19 1 views
0

삽입하는 동안 Environment.NewLine을 사용하여 datagridViewtextboxcell에 줄 바꿈 텍스트를 추가 할 수 있습니다. 하지만 첫 번째 줄에 밑줄을 추가하고 싶습니다. 그래서 내가 어떻게 vb.net에서 이것을 얻을 수datagridviewTextBoxCell의 첫 번째 줄 밑줄이있는 muti 줄 텍스트 Vb.net

지금은 (예 : 첫 번째 열에처럼) 날짜 형식에 대한 2 색으로 날짜를 보여주는 DGV의 페인트 방법을 처리 해요.

내가 밑줄을 그리려는 이메일과 세포 수에 대한 그 두 번째 마지막 열에서 첨부 된 이미지, enter image description here

을 찾아주세요.

감사합니다.

답변

0

나는 내 자신의 질문에 대답하고 있습니다. DataGridView1_CellPainting을 처리하고 특정 셀/열에 대해이 메서드를 호출합니다. 먼저 문자열을 분리하고 새 위치로 TextRenderer 클래스로 두 번 렌더링합니다.

이 올바른 방법은 모르겠지만 작동합니다.

Private Sub CellText_Underline(color As Color, e As DataGridViewCellPaintingEventArgs) 

    Dim text As String = e.FormattedValue.ToString() 

    Dim nameParts As String() = text.Split(" ") 

    Dim topLeft As New Point(e.CellBounds.X, CInt(e.CellBounds.Y + (e.CellBounds.Height/4))) 

    Dim arialBold As New Font("Arial", 11, FontStyle.Regular Xor FontStyle.Underline) 

    TextRenderer.DrawText(e.Graphics, nameParts(0), arialBold, topLeft, color) 

    Dim topLeft_1 As New Point(e.CellBounds.X, CInt(e.CellBounds.Y + (e.CellBounds.Height/4) + 5)) 
    Dim s As Size = TextRenderer.MeasureText(nameParts(0), arialBold) 
    Dim p As New Point(topLeft_1.X, topLeft_1.Y + 12) 

    Dim arialBold_1 As New Font("Arial", 11, FontStyle.Regular) 
    TextRenderer.DrawText(e.Graphics, nameParts(1), arialBold_1, p, SystemColors.WindowText) 
End Sub 

감사합니다.

관련 문제