Hide main form initially...Possible? (VB language) - vba

Is there a way to start a Windows Forms in (VB language) application with the main window not visible? Then later on when an external event occurs, I want to display the form.
How can I accomplish this?
Thanks.

Hint: See the 'Visible' property.

Initially you just put:
Load SuperAmazingForm
..then when you want to display the form, simply call its Show method as normal.
Doing it this way allows you to interact with the form's objects without the user being aware of it.

It depends on if you are doing this in Excel/Word or Access. If you are using Excel/Word then the Load MyForm syntax works. However, Access uses it's own variation of the standard UserForm. To load a form hidden you can do:DoCmd.OpenForm "MyAccessForm", WindowMode:=acHidden.

Related

Global FormClosing/Load events in .NET

I'm using VB.NET 4.7.2
I have a multi-form application and I'm coding the "Window" menu on top to show open forms so the user can easily switch (now that Win11 has forced combining applications on the taskbar).
I need each open form to be able to handle the FormOpening and Load events generated by other forms. My current solution is to handle those events locally in each form, which then triggers a custom global event that any other form can handle.
But that's a little tedious - is it possible for one form to handle another form's closing or opening without this workaround?
You could subclass a standard form to do all the scut work of registering with the shared global and hooking other forms events. You then just need to change the forms header to point at the subclasses type and off you go.

Reset usercontrol placed on form

Probably simple question but couldn't find any working solution. I have User control on windows form. I would like on button click placed on user control to reload user control. By reload i mean to reset all its variables and show again. How to achieve that?
There is nothing that does that. You could dispose the existing control and create a new one but noone would do that. Basically, it's a manual process. If you want the control's fields reset to defaults then you need to write code to do that. You might declare a Reset method and put all the code in there if that's appropriate and then you can simply call that method from the form.

Can't get a form to show in front of another

On my main form I call
WaitingForm.Show()
WaitingForm.Focus()
WaitingForm.Select()
and then run work in a backgroundworker. For some reason that form never opens in front of my main form though. How can I get it to show infront?
I assume you have instantialized this New Form if it was created programatically. In which case you can use the Topmost Property of the Form.
Hope that helps.
Use the Form.Owner property to make a form owned by another form. Assign its Owner property a reference to the form that will be the owner. For example:
WaitingForm.Show(Me)

How Can I Pass An Event Handler Outside Of A Custom Class

I have created a custom Textbox using a new class of which inherits. To this custom Textbox I have added two buttons (embedded) inside the control which are both declared inside the class. One button is for Search and the other for Clear.
The purpose behind these buttons is to populate a Listview control when using Search and Clear the results when using clear...pretty straight forward.
However, my issue that I need help with is...
Because I have declared these buttons inside of my custom class, I cannot work out how to pass a 'Click' event outside of the class and back to the form. For example, if I type into the Textbox and hit the search button, I somehow need to execute code on the click event (and same for clear).
I have read a little about not being able to pass event handlers outside of the class it was created, but I'm not really familiar with this.
Is there/and if so what is the best way to achieve my results? Is it possible to handle a click event outside of the class to pass information to other controls?
Any help appreciated. Thanks
Thanks to the comments from Hans Passant for putting me on the right track, I was able to refer to this site Raising Events and solve my issue.

Which control should be used for a scheduler and how?

I'm trying to do a scheduler for a lesson schedule. Which control should I use and how to do?
Here you find an image of what I'm trying.
You should create a UserControl based on the "DatePicker" control.
And then redefine the control template, using a UniformGrid.
There is no simple and quick way to do that yourself. Either you recreate a custom control based on a DatePicker, or you try to find a library of controls already doing what you are trying to.
I believe a few controls already exists to do that, but I don't have names to throw in.