CLR: .Net / Mono / Boo / Otros CLR > VB .NET
Codigo
(1/1)
Diego18p:
hola amigos soy nuevo en el foro, y quisiera que me ayudaran con un tema, lo que sucede es que necesito generar un formulario con textbox, button y un grilla, hasta ahi sin problema si no fuera porque lo tengo que hacer por codigo es decir generar por codigo mi formulario y generar po codigo mis objetos, pls alguien me podria ayudar se lo agradeceria muchisimo. Gracias Totales.
Diego
ElNapster:
Que version estas usando ??
Cualquiera que sea la version de visual studio .net te da la opcion a ver el codigo de tus objetos , osea te da el codigo desde que se crea el form y todos los objetos que se encuentran en el y asi todo el proyecto.
Te envio un ejemplo que tiene un form y un boton.
--- Código: vb.net --- Public Class Form1 Inherits System.Windows.Forms.Form #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. Friend WithEvents Button1 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button Me.SuspendLayout() ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(128, 112) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(96, 64) Me.Button1.TabIndex = 0 Me.Button1.Text = "Button1" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 266) Me.Controls.Add(Me.Button1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region End Class
Espero te sirva,
:comp:
EDGAR123:
Hola espero que mi respuesta te sirva pero tambien pudes hacer tus formularios con un metodo public o private.
y los puedes llamar desde un boton.
Este es un ejemplo.
Public Sub CreateMyForm()
' Creas una nueva instancia de formulario
Dim form1 As New Form()
' Creas dos botones aceptar y cancelar
Dim button1 As New Button()
Dim button2 As New Button()
' Le colas el texto al boton 1 "OK".
button1.Text = "OK"
' Posicion del boton en el Form
button1.Location = New Point(10, 10)
' Le colocas texto al boton 2 "Cancel".
button2.Text = "Cancel"
' posicion del boton2 en base al boton1
button2.Location = _
New Point(button1.Left, button1.Height + button1.Top + 10)
' Texto del Form
form1.Text = "My Dialog Box"
' Muestas la opcion ayuda
form1.HelpButton = True
' Defines estilo y borde
form1.FormBorderStyle = FormBorderStyle.FixedDialog
' Remover la obcion maximizar de la barra de titulo
form1.MaximizeBox = False
' mismo procedimieto para el boton minimizar
form1.MinimizeBox = False
' evento aceptar.
form1.AcceptButton = button1
' evento cancelar.
form1.CancelButton = button2
' Posicion de inicio del formulario
form1.StartPosition = FormStartPosition.CenterScreen
' Añadir botones al formulario
form1.Controls.Add(button1)
form1.Controls.Add(button2)
' Mostrar el formulario.
form1.ShowDialog()
End Sub
Despues lo madas llamar en el evento clic de un boton.
call CreateMyForm()
espero y te sirva es algo sencillo..
Navegación
Ir a la versión completa