• 쇼핑몰
  • 커뮤니티
  • 북마크

vb.net




[Controls] [vb.net] FlowLayoutPanel 동적 삽입하여 달력 만들기

하나를하더라도최선을
2019.09.29 20:48 1,076 0

본문



93212966061dab9c7783a922405bac10_1569757661_5769.png
 


Public Class FrmAppoint
    Private listFlDay As New List(Of FlowLayoutPanel)
    Private Sub FrmAppoint(ByVal sender As ObjectByVal e As System.EventArgs) Handles MyBase.Load
        Dim flDays As New FlowLayoutPanel
        flDays.Name = "flDays"
        flDays.Dock = DockStyle.Fill
        Me.Controls.Add(flDays)
        GenerateDayPanel(42)
        AddLabelDayToFlDay(5)
    End Sub
 
    Private Sub GenerateDayPanel(ByVal totalDays As Integer)
        Dim flDays As FlowLayoutPanel = Controls("flDays")
        flDays.Controls.Clear()
        listFlDay.Clear()
        For i As Integer = 1 To totalDays
            Dim fl As New FlowLayoutPanel
            fl.Name = "flDays" & i
            fl.Size = New Size(120120)
            fl.BackColor = Color.FromArgb(10000255)
            fl.BorderStyle = BorderStyle.FixedSingle
            flDays.Controls.Add(fl)
            listFlDay.Add(fl)
        Next
    End Sub
 
    Private Sub AddLabelDayToFlDay(ByVal startDay As Integer)
        Dim day As Integer = 1
        For i As Integer = startDay To listFlDay.Count - 1
            Dim lbl As New Label
            lbl.Name = "lblDay{i}"
            lbl.AutoSize = False
            lbl.TextAlign = ContentAlignment.MiddleRight
            lbl.Size = New Size(11618)
            lbl.Text = day
            lbl.Font = New Font("Microsoft Sans Serif"12)
            listFlDay(i - 1).Controls.Add(lbl)
            day += 1
        Next
    End Sub
End Class



댓글목록 0

등록된 댓글이 없습니다.