Click here to Skip to main content
Sign Up to vote bad
good
See more: VC7.1C++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 1:28am
Edited 8-Feb-13 12:48pm
Jibesh15.7K

Comments
Matthew Faithfull - 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 - 8-Feb-13 7:37am
the forms are .Net WinForms
Matthew Faithfull - 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 - 8-Feb-13 7:42am
the forms are .Net WinForms
Argonia - 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 - 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.

2 solutions

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  
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  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Christian Graus 544
1 Ron Beyer 296
2 OriginalGriff 258
3 samadhan_kshirsagar 229
4 Tadit Dash 193
0 Sergey Alexandrovich Kryukov 7,007
1 Prasad_Kulkarni 3,815
2 OriginalGriff 3,557
3 _Amy 3,372
4 CPallini 2,975


Advertise | Privacy | Mobile
Web04 | 2.6.130617.1 | Last Updated 8 Feb 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid