• Jueves 28 de Marzo de 2024, 20:16

Autor Tema:  Codigo  (Leído 1390 veces)

Diego18p

  • Nuevo Miembro
  • *
  • Mensajes: 1
    • Ver Perfil
Codigo
« en: Martes 19 de Enero de 2010, 05:44 »
0
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

  • Moderador
  • ******
  • Mensajes: 727
    • Ver Perfil
Re: Codigo
« Respuesta #1 en: Viernes 22 de Enero de 2010, 18:00 »
0
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
  1.  
  2. Public Class Form1
  3.     Inherits System.Windows.Forms.Form
  4.  
  5. #Region " Windows Form Designer generated code "
  6.  
  7.     Public Sub New()
  8.         MyBase.New()
  9.  
  10.         'This call is required by the Windows Form Designer.
  11.         InitializeComponent()
  12.  
  13.         'Add any initialization after the InitializeComponent() call
  14.  
  15.     End Sub
  16.  
  17.     'Form overrides dispose to clean up the component list.
  18.     Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
  19.         If disposing Then
  20.             If Not (components Is Nothing) Then
  21.                 components.Dispose()
  22.             End If
  23.         End If
  24.         MyBase.Dispose(disposing)
  25.     End Sub
  26.  
  27.     'Required by the Windows Form Designer
  28.     Private components As System.ComponentModel.IContainer
  29.  
  30.     'NOTE: The following procedure is required by the Windows Form Designer
  31.     'It can be modified using the Windows Form Designer.  
  32.     'Do not modify it using the code editor.
  33.     Friend WithEvents Button1 As System.Windows.Forms.Button
  34.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  35.         Me.Button1 = New System.Windows.Forms.Button
  36.         Me.SuspendLayout()
  37.         '
  38.         'Button1
  39.         '
  40.         Me.Button1.Location = New System.Drawing.Point(128, 112)
  41.         Me.Button1.Name = "Button1"
  42.         Me.Button1.Size = New System.Drawing.Size(96, 64)
  43.         Me.Button1.TabIndex = 0
  44.         Me.Button1.Text = "Button1"
  45.         '
  46.         'Form1
  47.         '
  48.         Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
  49.         Me.ClientSize = New System.Drawing.Size(292, 266)
  50.         Me.Controls.Add(Me.Button1)
  51.         Me.Name = "Form1"
  52.         Me.Text = "Form1"
  53.         Me.ResumeLayout(False)
  54.  
  55.     End Sub
  56.  
  57. #End Region
  58.  
  59. End Class
  60.  
  61.  
  62.  

Espero te sirva,

 :comp:
"Somos lo que imaginamos ser"
-- --------------------------------------------------------------
-ElNapster
-Designer / Developer Software
-GuaTemALa



EDGAR123

  • Nuevo Miembro
  • *
  • Mensajes: 11
  • Nacionalidad: mx
    • Ver Perfil
Re: Codigo
« Respuesta #2 en: Lunes 25 de Enero de 2010, 21:58 »
0
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..