How to capture Enter key press? [duplicate]

Form approach As scoota269 says, you should use onSubmit instead, cause pressing enter on a textbox will most likey trigger a form submit (if inside a form) <form action=”#” onsubmit=”handle”> <input type=”text” name=”txt” /> </form> <script> function handle(e){ e.preventDefault(); // Otherwise the form will be submitted alert(“FORM WAS SUBMITTED”); } </script> Textbox approach If you … Read more

Change the Textbox height?

Go into yourForm.Designer.cs Scroll down to your textbox. Example below is for textBox2 object. Add this this.textBox2.AutoSize = false; and set its size to whatever you want this.textBox2.Size = new System.Drawing.Size(142, 27); Will work like a charm – without setting multiline to true, but only until you change any option in designer itself (you will … Read more

automatically position text box in matplotlib

Just use annotate and specify axis coordinates. For example, “upper left” would be: plt.annotate(‘Something’, xy=(0.05, 0.95), xycoords=”axes fraction”) You could also get fancier and specify a constant offset in points: plt.annotate(‘Something’, xy=(0, 1), xytext=(12, -12), va=”top” xycoords=”axes fraction”, textcoords=”offset points”) For more explanation see the examples here and the more detailed examples here.

Executing viewmodels command on enter in TextBox

I know I am late to the party, but I got this to work for me. Try using Key=”Return” instead of Key=”Enter” Here is the full example <TextBox Text=”{Binding FieldThatIAmBindingToo, UpdateSourceTrigger=PropertyChanged}”> <TextBox.InputBindings> <KeyBinding Command=”{Binding AddCommand}” Key=”Return” /> </TextBox.InputBindings> </TextBox> Make sure to use UpdateSourceTrigger=PropertyChanged in your binding, otherwise the property will not be updated until … Read more

All my JavaFX TextFields have lines in them

This is a known unresolved bug. The problem seems to be that it isn’t reproducible for the developers. In the comments of the bug report the use of a jvm parameter is suggested: -Dprism.disableRegionCaching=true However, if anyone is able to reproduce this very rare bug, my suggestion is to: modify the modena css file until … Read more

Make TextBox uneditable

Using the TextBox.ReadOnly property TextBox.ReadOnly = true; For a Non-Grey background you can change the TextBox.BackColor property to SystemColors.Window Color textBox.BackColor = System.Drawing.SystemColors.Window; When this property is set to true, the contents of the control cannot be changed by the user at runtime. With this property set to true, you can still set the value … Read more

Text box with line wrapping in matplotlib?

The contents of this answer were merged into mpl master in https://github.com/matplotlib/matplotlib/pull/4342 and will be in the next feature release. Wow… This is a thorny problem… (And it exposes a lot of limitations in matplotlib’s text rendering…) This should (i.m.o.) be something that matplotlib has built-in, but it doesn’t. There have been a few threads … Read more

Paste Event in a WPF TextBox

Here’s some code I had lying around in case I ever needed it. Might help you. public Window1() { InitializeComponent(); // “tb” is a TextBox DataObject.AddPastingHandler(tb, OnPaste); } private void OnPaste(object sender, DataObjectPastingEventArgs e) { var isText = e.SourceDataObject.GetDataPresent(DataFormats.UnicodeText, true); if (!isText) return; var text = e.SourceDataObject.GetData(DataFormats.UnicodeText) as string; … }