根据月份。每天画一个listbox和label,并且为listbox添加事件
Private Sub DrawingPage()
TryEnd Sub
实现拖拽的三个方法
Private Sub ListBox_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Dim ListBox As ListBox = CType(sender, ListBox) '获取当前操作的控件对象,只有这样才能对该控件进行操作
Dim DragIndex As Integer = ListBox.IndexFromPoint(e.X, e.Y)
If DragIndex <> ListBox.NoMatches Then
ListBox.SelectedIndex = DragIndex
If e.Button = Windows.Forms.MouseButtons.Left Then
DoDragDrop(ListBox.Items(DragIndex), DragDropEffects.Copy)
ListBox.Items.Remove(ListBox.Items(DragIndex))
ElseIf e.Button = Windows.Forms.MouseButtons.Right Then
' DoDragDrop(ListBox1.Items(DragIndex), DragDropEffects.Move)
End If
End If
End Sub
Private Sub ListBox_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs)
e.Effect = e.AllowedEffect
End Sub
Private Sub ListBox_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs)
Dim ListBox As ListBox = CType(sender, ListBox) '获取当前操作的控件对象,只有这样才能对该控件进行操作
Dim item As Object = CType(e.Data.GetData(GetType(System.String)), System.Object)
Dim item2 As Integer = ListBox.IndexFromPoint(ListBox.PointToClient(New Point(e.X, e.Y)))
If item2 = -1 Then
ListBox.Items.Add(item)
Else
ListBox.Items.Insert(item2, item)
End If
'If e.AllowedEffect = DragDropEffects.Move Then
' ListBox1.Items.Remove(item)
'End If
End Sub
写入数据的方法。删掉了读取数据库的部分
For i As Integer = 0 To rst.RecordCount - 1
For Each ctrl As Control In Me.Controls
Dim yjdg As String = “这里是listbox的name属性,本文里就是日期)”
Dim zwcmHc As String =“显示的内容”
If ctrl.Name.Equals(yjdg) Then
Dim li As ListBox = CType(ctrl, ListBox)
li.Items.Add(zwcmHc)
End If
Next
rst.MoveNext()
Next