Solved

Data entry in a dialog form using multiple controls

Posted on 2004-09-13
5
176 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
  • 3
  • 2
5 Comments
 

Author Comment

by:Ghanisen
Comment Utility
Hi,

Sorry I'm using 3 textboxes and 1 DateTimePicker.

Thanks
0
 
LVL 8

Expert Comment

by:wguerram
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Hi wguerram,

Thanks, it works.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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 …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now