How to build a Main Menu screen - vb.net

Good day (and happy New Year),
I'm a beginner VB.Net programmer using VS 2008.
I'm planning a new winform project whose main form should look more or less like this:
MAIN MENU
1. DoSomething1
2. DoSomething2
3. DoSomething3
...
Please choose: [TextBox]
The user can either choose from the Main Menu (by clicking an item) or enter the item number in the textbox. For example, if the user clicks DoSomething3 in the Main Menu (or alternatively enters 3 in the textbox), another form will be opened and hide the main form.
What would be the best way to implement it?
Specifically, I would like to know how I make so that choosing from the menu and entering a number in the textbox fire the same event.
Any help or hints will be appreciated.

This is the traditional user interface for a console mode program. It is quite inappropriate for a GUI app, the kind that Winforms let you build. The closest approximation is buttons for each menu item. So the user can just click one directly, rather than having to type a number. The keyboard still works too, pressing Tab to move through the buttons, Space to activate one.
Look around a bit at user interfaces of other programs you use. Note their use of a menu and a toolbar.

Context Menu and Event Handling in Visual Basic .NET
Edit:
Ok. I think I did not understand. May these links will help you:
Multiple Forms in VB.NET. Part 2 - Accessing Controls on Other Forms
You can use buttons to goto other forms: Look at this thread:
Link from one form to another (Thread)

it's been almost 2 yrs i did not use vb.net but i'll try to help u.
you can make something very simple.e.g.
Have three buttons on the main menu of the main form e.g.
Button 1
Button 2
Button 3
Add click events to all the tree buttons. Create a method for button1,button2,button3
e.g.
void SimulateButton1
{
SpecifiedForm.show();
}
void SimulateButton2
{
SpecifiedForm.show();
}
void SimulateButton3
{
SpecifiedForm.show();
}
Now for the main menu its ok, lets consider entering the Number manually
//get the number first
String Choice=txtChoiceTextBox.getText();
You can add a button next to the textbox with caption Choose Option
and then add an onclick event to this button
on clicking on the button, do the following
if (Choice="1")
{
SimulateButton1();
return;
}
if (Choice="2")
{
SimulateButton2();
return;
}
if (Choice="3")
{
SimulateButton2();
return;
}
For the first tree button it mentioned, it can not be a button but a menu item but the principle is the same
that's it, hope it helps

Related

Disable "Config structure" button in VA02 Item detail?

I would like to hide the "Config structure" button in the header of the screen "Item derails: configuration" in the VA* transactions, for a certain item status.
I am debugging the Dynpro logic but it's quite difficult to find the right spot where I can implement my additional logic and what button it actually is (technically).
Any help and guidance is appreciated.
Thanks in advance.
Here is a way to locate the code which defines the buttons of the Application Toolbar in any Dynpro. You may then change the code to hide a button, etc.
The "Application Toolbar" is the line of buttons which appears at the top of the main screen area (what is shown in your screenshot), and it's selected by the ABAP statement SET PF-STATUS during the Process Before Output event of the Dynpro screen, right before the screen is displayed.
If you put the focus on the button (click without releasing and drag out of the button) and press the F1 key, you will see both the function code of the button and the GUI status it belongs to (screenshot for transaction code SE38):
Double-click the "Function" field to display the GUI Status:
You may then start the debugger (/h in the command field for instance) and use the feature "breakpoint at statement", to stop at every SET PF-STATUS. After the EXCLUDING word, you may exclude (hide) any function code you want (button, menu item or keyboard key; for information, here SYCR is not even defined in the GUI status, so it's ignored). As you can see, you may modify the code here:

How to click on a position of form or a control automatically?

I'm using Visual Basic 2008 (VB.NET) and I have an old control which have some buttons on it. These buttons can not be pressed without actual click and the control have no event or API for that. The control is something like the picture below which has multiple objects and buttons as a single control which controls inside the control can be changed dynamically according to some conditions but at a fixed place and this is why I think simulating a click that I said is the best way in my opinion:(The actual control is completely different that the picture below. It's only a sample)
I can click on the button by doing these steps:
Collecting all controls positions on my form
Moving the control in order to put the button exactly at the left top of the form
MyControl.Left = -43
MyControl.Top = -6
Moving form exactly to the center of the screen
Me.Location = New Point(Screen.PrimaryScreen.WorkingArea.Width / 2 - 1, Screen.PrimaryScreen.WorkingArea.Height / 2 - 1)
Simulating a click action at the center of the screen
Moving back controls to their positions that I got in the first step
It can be done that way but it's not reliable and it might not be user friendly for my program customers.
I want to ask if there are any better method to do that like simulating a click event on a position on the form itself (so I don't have to move controls and do other steps)?
Of course I feel I must tell you that simulating a mouse click in order to programmatically click a button is not a very good idea. Many things can go wrong with this method (The form could move, making your mouse click on the wrong location; Form could be minimized, or another form could be on top of it, etc)
That said, it is possible, so take a look at this article that contains the code to simulate a mouse click.
http://www.developerfusion.com/code/276/simulating-mouse-events/
Once again, please consider doing this a different way. Iterate through the controls in the user control until you find the button you want and use button.performclick. Or you can call the function that the button.click event calls yourself, if it is public

Triggering Visual Basic Keydown events without a specific function

I'm building on top of code that a previous developer has left me, and he left something that intrigued me quite a bit.
Basically on his menus, he has a TextBox to take in user input and a button next to it to submit the value of the TextBox (for example if the user wanted to select option 1, he would input 1 into the TextBox and click the button). However, the user could also press the Enter key while focusing the TextBox, and it would be treated as the submit button was clicked.
Now this is simple enough to do, but when I check the VB code behind the menu, there's no TextBox_Keydown(...) Handles TextBox.Keydown function anywhere, only the button click event. How is he doing this? He has several menus that are similar and I can't figure out how.
A standard dialog box, if not told to act otherwise, enter does default command button and escape does cancel. In VB look at the properties Default for the command button.
I discovered how he was doing it. He basically mapped the AcceptButton and CancelButton properties of the entire Windows Form to various button functions.

App calls Method on mouse click. How can I stop it?

So I am pretty new to Xcode and Objective C, I've been using it about 2 weeks now. I am building an app for OSX. One of the windows in the app has 5 text boxes, some labels and a submit button at the bottom. The submit button is linked to a method that closes the window, opens a new one and outputs the contents of the text boxes into one text field on the new window.
I had it working correctly, but now when I do anything but click on the top text field the submit method is called and the window closes. I can click on the black space in the window, but click on any of the objects calls the method. Also, pressing tab calls the method. I am not sure when I did to cause this error, but any insight or tips would be very useful.
Sorry if this is vague, I'm not even sure how to describe the problem. If you need any specific information please ask.
Try looking in Interface Builder. Ctrl Click or Right click on the each one of the fields that are responding with calling the function. See if they are linked to the function.
Also check the "responder" as was suggested earlier. You can do this by also right click or ctrl clicking the red responder box labeled "responder". See if anything in there maps to your function

Eclipse RCP : How to show message dialog after editor loads?

I am opening an editor from a view on click of a treenode. Now, when editor loads and controls are displayed to the user, I want to display a warning message dialog to the user based on certain values present on the editor.
I tried by putting the warning dialog at the end of createPartControl method of the editor. Dialog appears on double cliking the treenode as per the required functionality. But, the problem is that when the dialog appears, the controls on the editor are not yet visible. It's only when I close the dialog the editor controls are shown.
I want it to happen the other way around. i.e. The editor controls to show up first and then the warning dialog should appear. What changes should I do to achieve this effect?
You may want to call that MessageDialog in an asynchronous way, to leave the Editor the opportunity to complete itself, as suggested in this message.
show your warning dialog in an asyncExec() runnable would ensure that the editor's initialization all happens in the correct sequence.
So, something like (not tested) this code might do the trick:
getSite().getShell().getDisplay().asyncExec
(new Runnable() {
public void run() {
MessageDialog.openWarning(getSite().getShell(),"wrong","no)
}
});
}
Some other examples in this MapEditor class, where a MessageDialog is displayed through an asyncExec which waits for the result:
PlatformGIS.syncInDisplayThread