Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,

I have an application in which an input box is supposed to come up on the screen when i press a certain button. But the problem that i am facing is that the input box always comes below the application.
Is there any way to keep the input box always on top of all the applications ?

Thanks
Posted
Updated 9-May-20 4:36am

Taken this is Windows.Forms, if the dialog goes under your application, you should define the owner. See: Form.ShowDialog [^]

You can also set the TopMost[^] property to force the dialog on the highest level in Z-order.
 
Share this answer
 
Comments
ChrisRaisin 24-Sep-22 17:26pm    
Inputbox is not a dialog and so does not have "Topmost" property
InputBox always comes on topmost position for VB.NET.
TO check it out, create a new form & show InputBox on form load, you can see until you close the InputBox you cannot work on that form, from which InputBox is shown
 
Share this answer
 
This works but is probably not ideal

me.hide()
text=inputbox("enter the password ..",,,,)
me.show()
me.update()
 
Share this answer
 
Use the control "InputDialog" in a function call rather than using the function "InputBox" as showing in this following sample.
VB
Private Function GetPassword(Optional strCurrentPW as String = "") as string
  Dim strPassword As String = ""
  Dim InputPassword As New InputDialog
  With InputPassword
    .TopMost = True 'keep dialog on top
    .Text = "Password" 'text is the "Title" bar of the Dialog
  '''.btnOK.Visible = True 'True by default, shown for documentation purposes
  '''.btnCancel.Visible = True 'True by default, shown for documentation purposes 
    .txtValue.Text = strCurrentPW 'Initial value in the input area of the dialog
    .Prompt = "Please input your password" 'A prompt just above the input area
    .ShowDialog() 'display the dialogue and wait for response 
  End With
  If InputPassword.DialogResult = DialogResult.OK Then  'OK button clicked
    return InputPassword.value.trim
  else 
    return "" 
  endif
end function
The "topmost" setting will ensure the input box (or rather, Input Dialog") will appear above all other forms. I hope this helps.
 
Share this answer
 
Comments
CHill60 11-May-20 4:50am    
And where does this control come from? Microsoft have never heard of it.
ChrisRaisin 24-Sep-22 17:29pm    
Class: MahApps.Metro.Controls.Dialogs.lnputDialog

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900