I've created a messagebox which I want it to stay on top of program when it appears on the screen. It worked normally when I hadn't set my Form to stay on top, but now my msgbox hides under it and it's hard to take it on top to actually see it. Can you set msgbox on top somehow?
If you're creating your own messagebox, use the ShowDialog instead of the Show method to make the messagebox be on top regardless of the Topmost setting. This gives you the advantage of returning different results with different buttons used, the same as the built in messagebox.
Related
I am facing a problem with multiple forms.
When loaded, it doesn't show the tabs at the top which are part of the form and requires the user to scroll up.
I have done research. It may be related to the .SetFocus property.
Private Sub Form_Load()
Forms!frmEnrolementForm.Tab ("tabCtl0.SetFocus")
End Sub`
As I understand, user doesn't see the top part of window with tabs of tabcontrol. If so, reduce the size of tab control and whole window in order to fit in window on PC with minimal screen resolution. Also you can open desired tab page using code like
Forms!frmEnrolementForm.Page1.SetFocus
Here Page1 - is name of tabpage, not tab control. SetFocus is object method, not property.
It depends on the layout of your form, but you might be able to solve the issue by changing the "Tab Order" settings for the form.
It's under Form design tools > design > Tab Order, and you want the top/first items on your form to be at the top of the list. Ideally I'd say put all the items in a sensible order (e.g. starting with the top left and ending with the bottom right) for a good user experience, but the first item is the one that affects where the form opens.
Mine was opening in the middle of the page because my sub-form was set as the top item in the tab order, but I changed it to a button at the top of my form and now it always opens at the top.
I got this from user NeoPa in this forum answer.
At the top of the Properties Window in VS2010, I can see a list of all of the controls on my form. In that last, I see "PictureBox1," even though I don't see a corresponding PictureBox in the Form window.
I can change the location and size of the PictureBox, and set its image to a picture that should be noticeable. I still see nothing on the GUI form. If I can't find something to click on the GUI form, however, I don't know how to get rid of this superfluous PictureBox.
Is there some backdoor method that I can use to get rid of this PictureBox? It seems if the Properties Window lists it, it should offer some method to delete it.
A simple explanation is that it is covered by something else. Use View + (Other Windows) + Document Outline to see it. You can drag+drop it back on top. Or just right-click + Delete and its gone.
So I created a form, and have been using it for a while.
All of a sudden today it stopped working. Other forms load and can be viewed but not this one.
The weirdest part is that the controls still respond!
So I can't actually see the form but I can still interact with it. (only using keyboard no mouse clicks are responding) I know the form is enabled. But I simply can't see it! I have restarted excel, and the whole computer.
I even completely removed all code in the userform to see if I could get the blank shell to load, and while I can tell it loads (it disables everything in excel until I use Alt+F4) it still won't be visible. I have checked the Enabled, All Colors, Captiuon, Width, Height, Top, Left, StartUpPostion, SpecialEffect, Zoom, DrawBuffer properties and everything is fine.
I have also Exported and reimported it and still simply nothing. Also tried importing it into another Workbook, nothing. I at my wits end (not that it's very far to reach!)
Also, I can still see the userform in the designer I can still edit it, I get NO errors. This happens not only when calling the form in code, but even when running it right from the designer.
Any one ever have this issue? Any ideas or solutions?
The issue ended up being the Top and left properties. While I did check them, they way I checked them was not accurate; I still have no idea why, but I think it defiantly has something to do with dual monitor setup.
The way I tested double checked the forms top and left properties was by creating a new form and adding a button on the button click event I had a msgbox show the top and left properties of the form at time of clicking.
I then moved the new form to where I wanted the form that woudn't show to be and clicked the button; I then set these values to the form that wouldn't show.
I tested this location and made sure to match the properties with the values I wanted multiple times and it didn't work.
For some reason the values needed where about 1000 digits off (instead of 250 I needed to use 1250) even though I had set the form right where I wanted the new one to be and made sure to save the properties when they matched what I wanted
I've got two forms, one being frmMain and the other being frmDatasets. The idea is that frmDatasets is used to manage the application's datasets (it's a program for comparing sorting algorithms).
I have a MenuStrip on frmDatasets with a few items. I just decided to change the Add Dataset item to a drop-down menu with options for loading one from file, or generating one according to certain parameters. All well and good; just add the items, swap some icons around, and change the event handler's signature to handle the right Click event.
Except when I run the program, clicking on the Add Datasets top-level item for the first time sends frmDatasets to the back, displaying an inactive frmMain. Clicking the item again shows the dropdown menu as usual.
If I instead click another top-level menu item, that works just fine. But then simply hovering my mouse over the Add Dataset item causes the 'send to back' thing to happen.
I say "send to back", but it's really just putting it behind frmMain. It remains in front of other windows like Visual Studio and Firefox.
Anyone know what on Earth is going on with this form?
EDIT: If I show frmDatasets as a modal dialog, it stops the whole "sending to back" thing, but I still have to click the menu item twice before it shows the list.
EDIT2: Overriding the onClick event to call mnuAddDatasetDropDown.ShowDropDown removes the double-click issue, but it's only a solution if I keep the form as a modal dialog. Still gets sent to back. Overriding mouseEnter doesn't do anything to solve it.
Setting the TopMost property of frmDatasets from its Design view to 'true' fixed all of the problems I was having. No insight as to what was going on, unfortunately, but if anyone else is having this problem then hopefully it'll work for them too.
See my case is,
I am opening more than one forms (toplevel=false) inside a panel. All the forms opened inside that panel will be dock filled and brought to front during runtime. and my need in this situation is, how can i select the top most control(form) on that panel. Top most control means control(form) which is having greater z-order.
I am currently using this code by assumption,
panel.controls(0)
Can any body tell me, whether the above snippet is right or any alternate syntax available in dot net to achieve that.?
According to the MSDN:
The control with an index value of zero is at the top of the z-order, and higher numbers are closer to the bottom.
Therefore, I'd say your assumption was correct. Controls(0) will always be the top-most control. The only concern would be whether or not it is visible.
I don't see any other solution of looping through each Control and see what's the topmost one.
Something like:
Dim TopMostControl As Control = panel.Controls(0) 'Check if there are any control
For Each Control As Control In panel.Controls
If panel.Controls.GetChildIndex(Control) < panel.Controls.GetChildIndex(TopMostControl) Then
TopMostControl = Control
End If
Next