Underline letter in a button - c#

In my form, I have four buttons that do different tasks. The
button.Text field is set as &Next Project, so the N will be underlined.
In the preview of the form, it shows up with the N underlined. Yet
when I run my program, the text shows up with no underlining.

Press Alt.
Those keyshortcuts are only working in combination with the Alt-Key, and therefor only show up if it is pressed.
Also there seem to be two ways to always show the Mnemonics:
Change the Windows Desktop/Theme Settings:
Right Click Desktop -> Properties
Got to the Appereance Tab -> Effects
Uncheck "Hide Underlined letters for keyboard navigation until I press the ALT Key"
Change the System-Parameters via an API-Call.

Related

IntelliSense with C# (Unity) in VSCode disabling space to autocomplete

I like intellisense however I don't like how when I finish typing something like a method name that has the name "Press" tries to autocomplete to "buttonpress" and when I press space bar to go to the next word or part of the code, it autocompletes to that and it's super frustrating. Is there any way to disable pressing spacebar for autocompleting but keep Tab to autocomplete?
Edit: I found the way to disable Enter or Tab for this (acceptSelectedSuggestion), but it doesn't list Space as one of the buttons that accepts the autocomplete suggestion.
Go to File -> Preferences -> Settings -> Text Editor -> Suggestions -> Quick Suggestions -> Edit in settings.json and add this line
"editor.acceptSuggestionOnCommitCharacter": false

ToolStripMenuItem shortcut keys do not ender line with mouse click

I have a strange problem. I have a toolStripMenuItem that I wish to have the first letter underlined. This is in Windows Forms VS 2010.
It is defined in the designer with text equal to "&Expand" and show shortcut keys = true and shortcut keys = Alt+E. It shows up in the form in designer as expected with the E underlined.
I have a click event that changes the name, and then does something. If you click again it sets the name back
private void expandToolStripMenuItem_Click(object sender, EventArgs e)
{
if (expandToolStripMenuItem.Text == "&Expand")
{
expandToolStripMenuItem.Text = "Collaps&e";
expandToolStripMenuItem.ShortcutKeys = Keys.Alt | Keys.E;
// execute some other code
}
else
{
expandToolStripMenuItem.Text = "&Expand";
expandToolStripMenuItem.ShortcutKeys = Keys.Alt | Keys.E;
}
}
I also set the &Expand in the form shown and load events although this makes no difference.
Now when the form opens the E is not underlined. If I click it with the mouse it shows Collapse but the e is not underlined. I can go back and forth with the mouse and the letters are never underlined. However if I type AltE, the letter is underlined in both cases from that point on. Even with the mouse.
Any ideas?
Thanks
After my comment, I looked a little deeper. This is expected functionality and is configurable by the user.
In the Windows Control Panel in the Ease of Access Center, there is an option in the "Make the keyboard easier to use" section called "Make it easier to use keyboard shortcuts: Underline keyboard shortcuts and access keys". If that check box is unchecked the system will only underline access keys (the proper name for the shortcut underlining which you're dealing with) when the user is already navigating with access keys (using Alt). If the check box is checked then they will always be underlined.
You can test this with the file menu in pretty much any application in Windows.

Numeric keypad on MonoTouch

I have a problem when using MonoTouch.Dialog to create a login screen.
If you look at the screenshots below, for a user to login they must enter their mobile number and PIN. Both of these EntryElements use a numeric keypad. The first problem is that there is no way to move from the mobile number field to the pin field. Secondly once they have entered their pin there is no 'done' button or anything to dismiss the keyboard. It's very counter-intuitive for them to scroll up in order to poke the Login button (shown in the second screenshot).
How do I get the little bar with previous, next and done buttons as shown in the third screenshot? I've seen this on some apps and was wondering if it's possible to get this working using MonoTouch.Dialog?
Keyboard in the way:
How do you dismiss the keyboard?
Ideally this is what I want:
This other Stackoverflow answer shows how to add a "done" button on top of the keyboard. Using this method you can add other buttons, as well.
The answer is to create your own DialogViewController with the following:
private UIView _toolbar;
public override UIView InputAccessoryView
{
get
{
return _toolbar;
}
}
You then create whatever you want to display in the UIView that is returned. I used a UISegmentedControl for the Next and Prev buttons and a UIBarButtonItem for the Done button.

Push Button (On/Off) in C# Windows Forms

On the Windows Form application I have a Lamp image (a black and white one, and a bright one. For OFF and ON respectively).
Using the Button how can I achieve the scenario such that same button will turn the property of the image (pictureBox in my case) to show the Lamp as ON and pressing the same button again will turn the Lamp off.
I am accessing the 'Visible' property of picture box.
Put two images on top of each other and get the button to switch which one of them is enabled.
In the form designer you make one of them visible and the other non-visible. The code in the button handler can then be something like:
lightImage.Visible = !lightImage.Visible;
darkImage.Visible = != lightImage.Visible;
That will swap which one is visible and eliminate the need to keep state elsewhere.
A bit late to the party, but you can use a checkbox and set the appearance to button.
I think that would do what is expected by the original post.
I'm not sure about the way to put 2 images over each other, but if you want to reach the same effect:
place the 2 image files in your project resources
in the click event of the button, toggle the button image depending on a setting:
this would be in the click event:
Properties.Settings.Default.IsOptimizedForTracer !=Properties.Settings.Default.IsOptimizedForTracer;
if (!Properties.Settings.Default.IsOptimizedForTracer)
{
btnOptimizeForTracer.Image = Properties.Resources.TracerOFF;
return;
}
btnOptimizeForTracer.Image = Properties.Resources.TracerON;

Is there a way to press or fireup the keys in key board using c# code?

I want the 'Alt' to be pressed by code. It is like firing key-press event with key 'Alt' by the code, not hitting it manually. The need is, I have set 'ShortCut keys for menu, but it (the single underline on key letter) is not visible to the user unless he presses 'alt'. So i need to make the Alt be pressed by default.
Is there a way to 'press' or 'fireup' the keys in key board using c# code?
Check out the System.Windows.Forms.SendKeys class.
You can use the static Send method to send keystrokes to the active window. If you're trying to send keystrokes to another window, you'll need to use the Windows API to activate the other window first.
If you have any control over the operating system on which the program is being deployed, apparently you can force the underlined shortcut letter to always be displayed by going to Control Panel -> Display -> Appearance -> Effects -> Hide underlined letters for keyboard navigation.
(http://www.chinhdo.com/20080902/underlined-letters-windows/)
here is a complete article on use of SendKeys on codeproject
Here is how you simulate input (both mouse and keyboard).
http://msdn.microsoft.com/en-us/library/ms171548.aspx
If you look at the System.Windows.Forms.SendKeys class you will see that it provides you with what you want.
http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx

Categories

Resources