Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VC7.1 C++ C++/CLI
I have a simple visual c++ windows forms application, at the moment there is only one form in this project say the form is FormA, i want to add another form FormB to the current project.
 
Now it is required that there is a button titled as "Show FormB" on FormA.
Upon clicking this button the FormB should be visible to the user and
FormA should be disabled,
Next when the user closes the FormB, FormA should be available to the user again,
On FormB there is also some interaction with Sql-Lite database.
 
Any ideas/solutions will be welcomed warmly.
 

Thanks
 
[Edit] question rearranged for readability by Jibesh[/Edit]
Posted 8-Feb-13 2:28am
Edited 8-Feb-13 13:48pm
Jibesh16.6K
v2
Comments
Matthew Faithfull at 8-Feb-13 7:35am
   
You might want to clarify whether these 'forms' are .Net WinForms or MFC FormViews or completely custom Windows types you've written from scratch because the answer will depend heavily on what your 'forms' are.
partner99 at 8-Feb-13 7:37am
   
the forms are .Net WinForms
Matthew Faithfull at 8-Feb-13 7:49am
   
Ok that's not my bag but others will now be able to help more easily. You might even want to add C# to your tag list as .Net people who monitor that list may be more likely to know even if you're implementation is in C++/CLI.
partner99 at 8-Feb-13 7:42am
   
the forms are .Net WinForms
Argonia at 8-Feb-13 8:36am
   
Check the handler for the button click event and see if the member of the second CDialog [derived] class (assuming you mean dialog with form)calls DoModal()
Richard MacCutchan at 8-Feb-13 12:15pm
   
You have described the sequence of events you want, so what exactly is your problem? If you turn the above steps into code then it should work as you require.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This is a really bad idea. It looks like you want to show some sequence of forms, one at a time, like with a wizard. It can be something else. In any case, use only one form, just replace its content.
 
It the simplest form of it, it would be having a set of instanced of Panel filling the whole form and populated with controls you initially planned to have on each form. So a panel will represent a form content. Show only one form at a time, hide all others. Moving from one form to another one (for example, "Next") will be just hiding a visible panel and showing another one. You can design any more complex scenario.
 
—SA
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

It's not that tough to follow the steps you explained into code.
 
If you are displaying your FormB as Modal dialog { Form.ShowDialog() } from FormA,
 
just make the FormA.Visible = false;
Display Your FormB using ShowDialog
when you are done with Form
then call FormA.Visible = true;
 
There are other ways you can manage this UI behaviour. Its up to you and to choose whats best for you.
  Permalink  
v2

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

  Print Answers RSS
0 OriginalGriff 605
1 Maciej Los 319
2 BillWoodruff 184
3 Richard MacCutchan 180
4 Suraj Sahoo | Coding Passion 180
0 OriginalGriff 8,654
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,229
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 8 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100