|
分類:[VB.NET]
2006/06/16(Fri) 07:55:37 編集(投稿者) 2006/06/15(Thu) 19:51:51 編集(投稿者) 2006/06/15(Thu) 17:14:16 編集(投稿者)
ぽぴ王子さん 有難う御座いました
少し考えを変えてみて DateTimePickerの上にTextBoxを貼り付けたユーザーコントロールを作成してみました
aaDatePickerという名のユーザーコントロールで txt1というTextBoxと Picker1というDateTimePickerを使いました
Public Class aaDatePicker Private hei As Integer Private ptxt As String Private pTxtBox As TextBox
Private Sub Picker1_DropDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Picker1.DropDown Picker1.BringToFront() End Sub
Private Sub Picker1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Picker1.MouseDown txt1.BringToFront() End Sub
Private Sub Picker1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Picker1.MouseLeave txt1.BringToFront() End Sub
Private Sub Picker1_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Picker1.ValueChanged txt1.Text = DateValue(Picker1.Value) txt1.BringToFront() End Sub
ReadOnly Property DatePick() As DateTimePicker Get DatePick = Picker1 End Get End Property
ReadOnly Property txtBox() As TextBox Get txtBox = txt1 End Get End Property
Public Overrides Property BackColor() As Color Get BackColor = txt1.BackColor End Get Set(ByVal value As Color) txt1.BackColor = value End Set End Property
Public Overrides Property ForeColor() As Color Get ForeColor = txt1.ForeColor End Get Set(ByVal value As Color) txt1.ForeColor = value End Set End Property
Property myFont() As Font Get myFont = txt1.Font End Get Set(ByVal value As Font) txt1.Font = value Picker1.Font = value End Set End Property
Public Overrides Property Text() As String Get Text = txt1.Text End Get Set(ByVal value As String) txt1.Text = DateValue(value) End Set End Property
Private Sub aaDatePicer_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged Dim w As Integer = Me.Width
With txt1 .Width = w - 18 .Location = New System.Drawing.Point(0, 0) End With
With Picker1 .Width = w .Location = New System.Drawing.Point(0, 0) End With
Dim hi As Integer = txt1.Height Me.Height = hi
End Sub
Private Sub txt1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txt1.SizeChanged Dim hi As Integer = txt1.Height Me.Height = hi End Sub
End Class
簡単なテストでは一応無事動きましたが Fontはオーバーライドできませんでした
|