ParsX.com
پذیرش پروژه از دانشجویی ... تا سازمانی 09376225339
 
   ProfileProfile   Log in to check your private messagesLog in to check your private messages  |  FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups Log inLog in   RegisterRegister 

ایجاد کنترل در زمان RunTime

 
Post new topic   Reply to topic    ParsX.com Forum Index -> ويژوال بيسيك .NET
View previous topic :: View next topic  
Author Message
unknown
مدير بخش ويژوال بيسيك
مدير بخش ويژوال بيسيك


Joined: 05 Dec 2004
Posts: 439
Location: Tehran

PostPosted: Thu Dec 01, 2005 12:17 am    Post subject: ایجاد کنترل در زمان RunTime Reply with quote

براي اينکه بتوانيم از رويداد هاي يک شئ استفاده کنيم بايد از کلمه ي WithEvents قبل از نام آن شئ استفاده کرد. در ضمن وقتی از این کلمه استفاده می کنید نمی توانید متغییر را در زیر برنامه ها تعریف کنید. یعنی باید متغییر عمومی باشد. در این مثال وجود WithEvents الزامی است چون به صورت دینامیک کنترل را می سازیم و باید اعلام کنیم که می خواهیم از تمام رویداد های تعریف شده ی این شئ می خواهیم استفاده کنیم. اگر از WithEvents استفاده نمی شد نمی توانستیم از خاصیت Click آن استفاده کنیم. نام کنترل های معروف رو براتون نوشتم.
لذت ببرید...!




'Developed by Amir Moradabadi
Public WithEvents Command2 As CommandButton
'Controls:
    '1) = "VB.TextBox"
    '2) = "VB.CommandButton"
    '3) = "VB.Shape"
    '4) = "VB.Label"
    '5) = "VB.ListBox"
    '6) = "VB.PictureBox"
    '7) = "VB.Frame"
    '8) = "VB.HScrollBar"
    '9) = "VB.VScrollBar"
    '10)= "VB.Image"
    '11)= "VB.Line"
    '12)= "VB.DirListBox"
    '13)= "VB.DriveListBox"
    '14)= "VB.FileListBox"
    '15)= "VB.Timer"
    '16)= "VB.ComboBox"
    '17)= "VB.OptionButton"
    '18)= "VB.CheckBox"
   
Private Sub Command1_Click()
    Set Command2 = Me.Controls.Add("VB.CommandButton", "Command2", Me)

    With Command2
        .Visible = True
        .Width = 900
        .Height = 900
        .Left = Me.Width / 2 - .Width / 2
        .Top = Me.Height / 2 - .Height / 2
        .Caption = "Test Button"
    End With
End Sub

Private Sub Command2_Click()
    MsgBox "Button Pressed"
End Sub
Back to top
Display posts from previous:   
Post new topic   Reply to topic    ParsX.com Forum Index -> ويژوال بيسيك .NET All times are GMT + 3.5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum