Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Data entry in a dialog form using multiple controls

Posted on 2004-09-13
5
Medium Priority
?
183 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 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

722 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