Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Visual Studio 2008

Posted on 2010-09-20
7
Medium Priority
?
616 Views
Last Modified: 2012-05-10
I would liike a form to always be on top.  In VB 6.0 that was accomplished by using modal.
I am told to use Showdialog in .Net  When I use ShowDialog, as soon as any command button is pressed on the form it closes.  It does nevertheless stay on top with showDialog until closing.

Also If I use TopMost = true, the form remains on top, but the user can still select a command button on the form underneath the top most form.  I would like to accomplish the form always being on top and the command buttons on the form below the top most to be visible but unresponsive by the end user.  This was done by opening a form in modal in VB 6.0  How can this be accomplished in Visual Studio 2008?
0
Comment
Question by:dastaub
  • 2
  • 2
  • 2
  • +1
7 Comments
 

Expert Comment

by:frostfire01
ID: 33722784
You need to do both.

Set Topmost=True on the child form, and use FormName.ShowDialog() to open the form from the parent. The result is a modal window and you can see but not interact with the parent form.

Hope this helps.
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33722887
In your Form1 set a button for testing purposes...
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim obj As New Form2
        obj.ShowDialog()
    End Sub
in form2
 Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.TopMost = True
    End Sub
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33722917
Or if you mean that the form should be on the top of your screen...set:
 Me.StartPosition = FormStartPosition.Manual
        Me.Location = New Point(0, 0)
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 33725200
"When I use ShowDialog, as soon as any command button is pressed on the form it closes."

Something is not right there...

...can you show use the code on your "dialog" form?
0
 

Author Comment

by:dastaub
ID: 33731446
i did not want to question to be closed.
0
 

Author Closing Comment

by:dastaub
ID: 33731451
you caught the core issue.

Something is not right there...

Is there a property of a command button that can cause the form to close?  the original command buttons were copy and pasted from another form.  When I deleted and started from fresh regarding the command buttons, the error was then resolved.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 33731466
Yes...when you select the FORM itself, there is an AcceptButton() and a CancelButton() property that can be set to buttons on your form.  When buttons are set as these properties, clicking them will the cause the DialogResult() property of the Form to be set to "Ok" or "Cancel" respectively.  When DialogResult() is set on a form it immediately HIDES and execution returns to the ShowDialog() call that opened it in the first place.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

783 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