Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Mr. programmers if I can orient please'm doing an application and have problems trying to call it from another form controls

for example I have a form called wfrm_diseño_mesas on this form I need to call controls another form called wfrm_comanda

this is my mistake please

error that I have tells me that the controls are private and I leave the public to call them from another form

This form is called Wfrm_diseño_mesas

WFrm_COMANDA.txtdescripcion.Text = Convert.ToString(DataGridView1.Rows.Item(z).Cells(6).Value)

What I have tried:

I need to call from another form buttons and boxes
Posted
Updated 5-Aug-16 10:29am

Don't.
It's a bad idea - it locks the design of the two forms together, so you can't reuse them independently, or change one without considering the effects that could have on other forms.
Instead, use a combination of events and properties to let each form do the "donkey work" itself, and expose sufficient events and properties to allow the outside world to tell it what to do.

Exactly how depends on the "relationship" between the two forms.
Have a look at these, one of them will fit
The form that creates an instance of another:
C#
MyForm mf = new MyForm();
mf.Show();
Is the "parent", the other form is the "child".
(This doesn't imply any formal MDI relationship)

Transferring information between two forms, Part 1: Parent to Child[^]
Transferring information between two forms, Part 2: Child to Parent[^]
Transferring information between two forms, Part 3: Child to Child[^]
 
Share this answer
 
I have reason locks the controls
to put public

C#
child form



VB.NET
Public Property descripcion() As String
       Get
           Return txtdescripcion.Text
       End Get
       Set(ByVal value As String)
           txtdescripcion.Text = value
       End Set
   End Property
   Public Property dnruc() As String
       Get
           Return txtdnruc.Text
       End Get
       Set(ByVal value As String)
           txtdnruc.Text = value
       End Set
   End Property
   Public Property nom() As String
       Get
           Return txtnom.Text
       End Get
       Set(ByVal value As String)
           txtnom.Text = value
       End Set
   End Property

   Public Property BoxX2() As String
       Get
           Return TextBoxX2.Text
       End Get
       Set(ByVal value As String)
           TextBoxX2.Text = value
       End Set
   End Property

   Public Property Activarregistrar() As Boolean
       Get
           Return ButtonRegistrar.Enabled

       End Get
       Set(ByVal value As Boolean)
           ButtonRegistrar.Enabled = value
       End Set
   End Property
   Public Property Modificar1() As Boolean
       Get
           Return ButttonModificar.Enabled

       End Get
       Set(ByVal value As Boolean)
           ButttonModificar.Enabled = value
       End Set
   End Property

   Public Property Cobrar1() As Boolean
       Get
           Return ButtonCobrar.Enabled

       End Get
       Set(ByVal value As Boolean)
           ButtonCobrar.Enabled = value
       End Set
   End Property

   Public Property Nuevo1() As Boolean
       Get
           Return ButtonNuevo.Enabled

       End Get
       Set(ByVal value As Boolean)
           ButtonNuevo.Enabled = value
       End Set
   End Property


parent form


VB.NET
           Public Sub obtenerDatosComanda()

Formulario2.Activarregistrar = False
                '
                Formulario2.Modificar1 = True
                

                Formulario2.Cobrar1 = True
             
                Formulario2.Nuevo1 = True

                End Sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900