Results 1 to 15 of 15

Thread: Create Forms

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2004
    Posts
    235

    Create Forms

    Example I got these two forms, A and B.

    When I click on a date at formA, it should give me formB. Let say the date is 27/4 and wrote something in formB.

    When I click on a date(28/4) at formA, it should give me formB, but this time, it is a brand new formB.

    I exited formB and return to formA, I click on 27/4, how do I make it to show me back formB which I have written something in ?

  2. #2
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    HI,

    You need to post the code you are using to instantiate and view form2 and how you get bact to form1 from form2.

    I would guess that you have done something like:

    In a form2 event:
    VB Code:
    1. Dim frm2 As New Form2
    2. frm2.ShowDialog()

    Every time you call that event you are creating a new instance of form2, whether or not the previous frm2 has gone out of scope.

    It sounds as if what you need is to use a module Sub Main as your startup object and then in the module

    VB Code:
    1. Public frm1 As New form1
    2. Public frm2 As New form2
    3.  
    4. Public Sub Main()
    5.   Application.Run(frm1)
    6. End Sub.

    In the appropriate event in form1 put:
    VB Code:
    1. frm2.showdialog()

    Now, when you close frm2 it will still be available for the next call of that event. It will NOT have been disposed.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  3. #3
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    post some code.

    more than likely, you are instantiating a new form upon clicking that date. You will get a new form each and everytime like that.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jul 2004
    Posts
    235
    If test = "one" Then
    If (DatePicker1.Value >= DateTime.Today) Then
    cf2.TextBox1.Text = CStr(DatePicker1.Value)
    cf2.Show()
    Me.Hide()
    End If
    End If

    cf2 is form2.

    So example DatePicker1.Value is 28/7. Then I did something to it like clicking a label making it disabled.

    After that, I click the X button to return to form1 using form2_closing event.

    When I'm in form1, I click on 28/7, I want to see the label disabled.

    When back to form1, I click on 29/7, it should give me a brand new form2 with the label enabled.

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Just when you're 'closing' form2, make sure you save the values corresponding to that date somewhere. This way, when you click on that date again from form1, you only need to pull that data back up again and display it. Else, leave the fields blank.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jul 2004
    Posts
    235
    how do i save those datas ??

    to ?

  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    to... a database.

    Or better, an XML file.

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jul 2004
    Posts
    235
    yah...how do i save those data to XML ??
    i ask that in another post of mine...

  9. #9
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Yes, I am currently hopping between the two.

    Now whenever you call up form2, make sure you pass a value to it so that you can retrieve its corresponding data.

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Jul 2004
    Posts
    235
    erm...but do pass it to xml ?

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Jul 2004
    Posts
    235
    can i paste my codes to let you see...

  12. #12
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Sorry buddy, I'm not understanding you. These last two posts are well, uhm... "uhm".

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Jul 2004
    Posts
    235
    how do i write my things to XML...

    then how do i read them from form2 ?

    i do not know how to link

  14. #14

  15. #15
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi,

    There is no need to save ( and no advantage in saving) the data outside of your form objects. The code you posted,

    VB Code:
    1. If test = "one" Then
    2. If (DatePicker1.Value >= DateTime.Today) Then
    3. cf2.TextBox1.Text = CStr(DatePicker1.Value)
    4. cf2.Show()
    5. Me.Hide()
    6. End If
    7. End If


    works perfectly well. I had no problems when I cut and pasted your coded into a project.

    Refer to your latest thread on this subject.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width