Solved

Data entry in a dialog form using multiple controls

Posted on 2004-09-13
5
181 Views
Last Modified: 2010-04-23
Hi,

I want to use a Windows form (frmSaisieDialog) to enter a new record by returning entered data to the parent form (frmParent), and also to update an existing record from data sent by the parent form (frmParent) to the data entry form frmSaisieDialog). I'm using 4 textboxes to enter/display data in frmParent.

To do this in one direction, that is data entry, it is straithforward using an object (Public Class Donnees)to store the data:

Public ReadOnly Property Donnees() As Donnees
        Get
            Dim don As New Donnees
            don.Nom = Me.txtNom.Text
            don.Prenom = Me.txtPrenom.Text
            don.Naissance = Me.dtpNaissance.Value
            don.Charge = Me.txtCharge.Text
            Return don
        End Get
    End Property

Public Class Donnees

    Public Nom As String
    Public Prenom As String
    Public Naissance As Date
    Public Charge As Integer

End Class

This is fine for entering a new record, but it doesn't allow to display data sent from the parent form (for updating) because the public property Donnees is ReadOnly.

If I remove the ReadOnly to get the Get and Set sequence I obtain this:

Public Property Donnees() As Donnees
        Get
            Dim don As New Donnees
            don.Nom = Me.txtNom.Text
            don.Prenom = Me.txtPrenom.Text
            don.Naissance = Me.dtpNaissance.Value
            don.Charge = Me.txtCharge.Text
            Return don
        End Get
        Set(ByVal Value As Donnees)


        End Set
    End Property

The problem is how to write the SET part to be able to send data from the parent form for updating.

Any help shall be greatly appreciated.
0
Comment
Question by:Ghanisen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 

Author Comment

by:Ghanisen
ID: 12047610
Hi,

Sorry I'm using 3 textboxes and 1 DateTimePicker.

Thanks
0
 
LVL 8

Expert Comment

by:wguerram
ID: 12048199
Declare donees var as public

Public don As New Donnees

in you entry form

this way you don't need a propery, don becomes a  property of the form.
0
 
LVL 8

Expert Comment

by:wguerram
ID: 12048256
or if wnat to do it via the property this is the code:

'Form declaration section
private  don As New Donnees

public Property Donnees() As Donnees
        Get
            don.Nom = Me.txtNom.Text
            don.Prenom = Me.txtPrenom.Text
            don.Naissance = Me.dtpNaissance.Value
            don.Charge = Me.txtCharge.Text
            Return don
        End Get
        Set(ByVal Value As Donnees)
            don.Nom = Value.Nom
            don.Prenom = Value.Prenom
            don.Naissance = Value.Naissance
            don.Charge = Value.Charge
        End Set
    End Property

So before you call your Entry form do this:

dim MyDon as new Donnees

'Initialize Don members from you parent form values
MyDon.Nom = 'Nom'

MyEntryForm.Donnees = MyDon
MyEntryForm.ShowDialog
0
 
LVL 8

Accepted Solution

by:
wguerram earned 500 total points
ID: 12048282
Sorry instead of assigning the values to the class, you want them in the textbox, so here is the code for the property:

In the Set statement

public Property Donnees() As Donnees
        Get
            don.Nom = Me.txtNom.Text
            don.Prenom = Me.txtPrenom.Text
            don.Naissance = Me.dtpNaissance.Value
            don.Charge = Me.txtCharge.Text
            Return don
        End Get
        Set(ByVal Value As Donnees)
            Me.txtNom.Text = Value.Nom
            Me.txtPrenom.Text = Value.Prenom
            Me.dtpNaissance.Value = Value.Naissance
            Me.txtCharge.Text = Value.Charge
        End Set
    End Property
0
 

Author Comment

by:Ghanisen
ID: 12048747
Hi wguerram,

Thanks, it works.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question