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
Solved

Visual Studio 2008

Posted on 2010-09-20
7
590 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 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 85

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

838 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