Visual Basic 2010
-
28 aprilie 2010 09:50În Visual Basic 5 am un buton de comandă. Copiez apoi lipesc. Sunt anunţat că există deja un buton cu acest nume şi sunt întrebat dacă vreau o matrice (vector). După confirmare am două butoane cu acelaşi nume unul cu indice 0 şi altul cu indice 1. Acest lucru nu pot face în Visual Basic 2010, nu se oferă posibilitatea să creez matrice. Întrebare: Cum pot realiza acest lucru în Visual Basic 2010?
Toate mesajele
-
4 mai 2010 12:36
Se pot adauga butoane dinamic, pe Form_Load
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim b(2) As Button b(0) = New Button() b(1) = New Button() b(0).Name = "b0" b(0).TabIndex = 1 b(0).Text = "b0" b(0).UseVisualStyleBackColor = True b(0).Location = New System.Drawing.Point(100, 100) b(0).Size = New System.Drawing.Size(100, 50) b(1).Name = "b1" b(1).TabIndex = 2 b(1).Text = "b1" b(1).UseVisualStyleBackColor = True b(1).Location = New System.Drawing.Point(100, 200) b(1).Size = New System.Drawing.Size(100, 50) Me.Controls.Add(b(0)) Me.Controls.Add(b(1)) b(0).Visible = True b(1).Visible = True End Sub- Propus ca răspuns de Mila Daniel OvidiuMicrosoft Employee 19 august 2010 06:54
- Marcat ca răspuns de Denis ChiurtuOwner 23 august 2010 07:45
-
7 mai 2010 16:50
Option Strict On Public Class Form1 Dim button_() As Button Dim Buttons As List(Of Button) = New List(Of Button) Dim ButtonCount As Integer = 5 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim Array_Size As Integer = 5 ReDim button_(Array_Size) For i = 0 To Array_Size button_(i) = New Button button_(i).Size = New System.Drawing.Size(100, 25) button_(i).Top = 25 * i button_(i).Text = "Butonul " + i.ToString button_(i).TabIndex = i + 1 button_(i).UseVisualStyleBackColor = True Me.Controls.Add(button_(i)) Next '//sau For I As Integer = 1 To ButtonCount Dim B As Button = New Button B.Name = "btnInfo" & I.ToString B.Location = New Point(100, 25 * I) B.Size = New Size(100, 25) B.Text = "Info #" & I.ToString AddHandler B.Click, AddressOf infoButton_Click Buttons.Add(B) Me.Controls.Add(B) Next End Sub Private Sub infoButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Console.WriteLine(sender.ToString) End Sub End Class- Propus ca răspuns de Mila Daniel OvidiuMicrosoft Employee 19 august 2010 06:54
- Marcat ca răspuns de Denis ChiurtuOwner 23 august 2010 07:45