textbox

Handling ENTER button in TextBox, ASP.NET

狂风中的少年 提交于 2020-02-21 13:05:06
问题 I have the following problem in ASP.NET: there is a form that contains a textbox and a button next to it that is supposed to be pressed by the user after filling the box (sample on http://www.burnthespam.info, click "Pick your one", or when using ReCaptcha in a popup). Often, instead, users press ENTER key to submit the form. This doesn't cause the click event on the button to be triggered and possibly cause an unexpected behaviour. In burnthespam, I "tried" to solve by checking if there is

Text Box Text Changed event in WPF

不想你离开。 提交于 2020-02-21 11:13:53
问题 So, for example if I have 2 text boxes in WFA. The following code works. private void textBox1_TextChanged(object sender, EventArgs e) { textBox2.Text = textBox1.Text; } And I get this. The text in the second text box equals to the text in the first one, when I change it. But when it comes to WPF, I get a completely different behavior. When I do this. private void textBox_TextChanged(object sender, TextChangedEventArgs e) { textBox1.Text = textBox.Text; } And press Ctrl+F5 to test the

Text Box Text Changed event in WPF

这一生的挚爱 提交于 2020-02-21 11:13:51
问题 So, for example if I have 2 text boxes in WFA. The following code works. private void textBox1_TextChanged(object sender, EventArgs e) { textBox2.Text = textBox1.Text; } And I get this. The text in the second text box equals to the text in the first one, when I change it. But when it comes to WPF, I get a completely different behavior. When I do this. private void textBox_TextChanged(object sender, TextChangedEventArgs e) { textBox1.Text = textBox.Text; } And press Ctrl+F5 to test the

Regex in PreviewTextInput: only decimals between 0.0 and 1.0

好久不见. 提交于 2020-02-08 09:26:25
问题 I'd like to have a regex, which only allows digits between 0.0 and 1.0 in a textbox. BUT it should be in the method PreviewTextInput (C#, WPF project) So the normal regex doesn't work Regex regex = new Regex(@"^0|0.0|0\.[0-9]*|1\.0|1$"); I've found a regex, which allows all decimals in the PreviewTextInput method: Regex regex = new Regex("^[.][0-9]+$|^[0-1.]*[.,]{0,1}[0-9]*$"); How can a change this regex to only accept decimals between 0-1? Thanks. My method for decimals: private void tb

How to use TextBox.GetPositionFromCharIndex to show the vertical scrollbar only when needed?

☆樱花仙子☆ 提交于 2020-02-07 06:02:55
问题 Starting from this previous question, I have the following method: internal static int NumberOfPhysicalLinesInTextBox(TextBox tb) { int lc = 0; while (tb.GetFirstCharIndexFromLine(lc) != -1) { ++lc; } return lc; } For a currently unknown reason, it does not work in the context where I need it, so I tried another solution. I created a new multiline TextBox , with no character in it. I type in it only an Enter (it shows up in the Text property as "\r\n", so 2 chars). The method above,

How to use TextBox.GetPositionFromCharIndex to show the vertical scrollbar only when needed?

陌路散爱 提交于 2020-02-07 05:59:35
问题 Starting from this previous question, I have the following method: internal static int NumberOfPhysicalLinesInTextBox(TextBox tb) { int lc = 0; while (tb.GetFirstCharIndexFromLine(lc) != -1) { ++lc; } return lc; } For a currently unknown reason, it does not work in the context where I need it, so I tried another solution. I created a new multiline TextBox , with no character in it. I type in it only an Enter (it shows up in the Text property as "\r\n", so 2 chars). The method above,

WPF - How to disable drag and drop WITHIN a textbox control?

扶醉桌前 提交于 2020-02-06 04:27:22
问题 If you look at how textboxes appear in Windows Explorer - if you rename a file it highlights the entire text. But if you drag to select text, it will change the selection to fit the user's drag. In WPF, if you select all the text of a textbox, then drag in the text area to select text, it will try and drag & drop the text within the textbox area. I was wondering if there was a way in WPF to disable this functionality, to have it more like Windows Explorer? It's needed mostly because when

WPF - How to disable drag and drop WITHIN a textbox control?

二次信任 提交于 2020-02-06 04:27:12
问题 If you look at how textboxes appear in Windows Explorer - if you rename a file it highlights the entire text. But if you drag to select text, it will change the selection to fit the user's drag. In WPF, if you select all the text of a textbox, then drag in the text area to select text, it will try and drag & drop the text within the textbox area. I was wondering if there was a way in WPF to disable this functionality, to have it more like Windows Explorer? It's needed mostly because when

How can I allow only one decimal point in a textbox?

橙三吉。 提交于 2020-02-05 05:40:26
问题 Here is the code in C# to allow only one decimal point in a textbox: if textbox5.text.contains(".") && e.keychar="." { e.handled=true } I have to use it in VB.NET 2003 version, but I can't use the contains property. How can I do this? 回答1: How about using the Text.IndexOf(".") method instead? If it returns >=0 then you already have a decimal point. If (textbox5.Text.IndexOf(".") >= 0 And e.KeyChar = ".") Then e.Handled = True 回答2: Don't forget about the user's locale and number formats. I

How to stop Control-I from inserting a tab in a UWP TextBox at CoreWindow scope?

女生的网名这么多〃 提交于 2020-02-04 03:58:28
问题 Strange behavior (to me) when I have a TextBox in a UWP app. Create a Universal, Blank App UWP app in Windows 10. Add a TextBox to the default grid with this code: <TextBox Text="There's not much spam in it" Name="textBox" /> Build and run the application. Click inside of the TextBox Type Control-I. A tab is inserted. What causes this behavior? I'm trying to set up window level shortcuts in a Windows 10 application by hooking up a handler to Window.Current.CoreWindow.KeyDown , but I think