VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > VB.net教程 >
  • vb.net教程之改变窗体的背景颜色

改变窗体的背景颜色
 

Dim ctl As Control
        IsMdiContainer = True
        ' Loop through controls, 
        ' looking for controls of MdiClient type.
        For Each ctl In Me.Controls
            If TypeOf (ctl) Is MdiClient Then
 
                ' If the control is the correct type,
                ' change the color.
                ctl.BackColor = System.Drawing.Color.PaleGreen
            End If
        Next
    End Sub
7(2)
 Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
        BackColor = System.Drawing.Color.PaleGreen
    End Sub
或BackColor= Color.Blue

系统颜色:

GroupBox3.BackColor = Control.DefaultBackColor
 
8.绘制椭圆窗体
        Dim shape As New System.Drawing.Drawing2D.GraphicsPath
        shape.AddEllipse(0, 0, Me.Width, Me.Height)
        Me.Region = New System.Drawing.Region(shape)
9.获取当前时间
'Display the time
       Text1.Text = Now.ToLongTimeString  (只有时间  20 :55 :36)
  Text1.Text = Now   (有日期和时间   2012/1/29  20 :57 :36)
Text1.Text = Today  (只有日期   2012/1/29)
10.用鼠标滚轮调整窗体的透明度
Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel
        Static m As Integer
        If m > 1 And m <= 100 And e.Delta > 0 Then
            m = m + 5
        ElseIf m > 1 And m <= 100 And e.Delta < 0 Then
            m = m - 5
        Else
            m = 100
        End If
        Me.Opacity = m * 0.01
        TextBox1.Text = m
        Me.TopMost = True
    End Sub
 

11.绝对坐标

Control.MousePosition.X - 25
     Control.MousePosition.Y
Control.MousePosition

12.相对坐标

.e.X         e.Y

13.调用窗体的Paint事件

Me.Invalidate()  

相关教程