| Как да създадем контрол run time.За начинаещи. |
| Автор |
mara (09.11.2004 11:25) |
 |
съобщение до автора |
|
| Погледнат |
2017 пъти |
 |
добави към любими |
|
| Оценка |
 |
 |
добави коментар |
|
| Гласове |
1 |
 |
изпрати на приятел |
|
| Коментари |
(0) |
 |
абонирай се за C-Cplusplus |
|
|
|
|
|
|
|
| |
|
Public Class Form1
Inherits System.Windows.Forms.Form
Dim btnCTL As Button = New Button
Dim lstCTL As ListBox = New ListBox
Dim lblCTL As Label = New Label
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(330, 58)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = " Example of adding controls at runtime"
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With btnCTL
.BackColor = Color.Bisque
.ForeColor = Color.Black
.FlatStyle = FlatStyle.Standard
.Location = New Point(10, 4)
.Size = New Size(60, 50)
.Text = "Бутон"
.Show()
End With
With lstCTL
.BackColor = Color.Bisque
.ForeColor = Color.Black
.Location = New Point(80, 4)
.Items.Add("Това е listbox")
.Items.Add("контрола е вече въведен")
.Items.Add("в runtime.")
.Size = New Size(120, 50)
.Show()
End With
With lblCTL
.BackColor = Color.Bisque
.ForeColor = Color.Black
.Location = New Point(210, 4)
.Size = New Size(114, 50)
.Text = "Този label control също"
.Show()
End With
AddHandler btnCTL.Click, AddressOf btnClicked
AddHandler lblCTL.MouseDown, AddressOf lblMouseOver
AddHandler lstCTL.SelectedValueChanged, AddressOf lstItemChanged
Me.Controls.Add(btnCTL)
Me.Controls.Add(lstCTL)
Me.Controls.Add(lblCTL)
End Sub
Private Sub lblMouseOver(ByVal sender As Object, ByVal e As MouseEventArgs)
If lblCTL.BorderStyle <> BorderStyle.Fixed3D Then
lblCTL.BorderStyle = BorderStyle.Fixed3D
Else
lblCTL.BorderStyle = BorderStyle.FixedSingle
End If
End Sub
Private Sub btnClicked(ByVal source As Object, ByVal e As EventArgs)
MsgBox("Това е твоят любим контрол!")
End Sub
Private Sub lstItemChanged(ByVal sender As Object, ByVal e As EventArgs)
MsgBox(lstCTL.SelectedItem)
End Sub
End Class
| 1 посетител чете този скрипт (0 потребители и 1 гост) |
|
|
Активни потребители:
---
|
| |
|
|