textbox

WPF how to make textbox lose focus after hitting enter

耗尽温柔 提交于 2019-12-20 12:35:18
问题 I created some textboxes and I want user to enter decimal values into them. In every application I have ever used, when I type something into the textbox and hit enter, the value is accepted and textbox lose focus. How can I do it in my app? I know it should be relatively easy to do it with a key event, but maybe there is a command or something. I searched the stackoverflow but I only found questions about how to keep focus after hitting enter... 回答1: You can also create a generic behavior

WPF how do I create a textbox dynamically and find the textbox on a button click?

拥有回忆 提交于 2019-12-20 10:28:51
问题 I am creating a TextBox and a Button dynamically using the following code: Button btnClickMe = new Button(); btnClickMe.Content = "Click Me"; btnClickMe.Name = "btnClickMe"; btnClickMe.Click += new RoutedEventHandler(this.CallMeClick); someStackPanel.Childern.Add(btnClickMe); TextBox txtNumber = new TextBox(); txtNumber.Name = "txtNumber"; txtNumber.Text = "1776"; someStackPanel.Childern.Add(txtNumber); I hook up to a click event to the Click Me button. The click me button even is fired

Textbox padding

泪湿孤枕 提交于 2019-12-20 09:49:55
问题 I've searched through the internet, I must be using the wrong keywords because I can't find anything. I want to create a textbox that has text starting from a little far from the left. Just like that. 回答1: As you have most likely discovered, Winforms Textboxes do not have a padding property. Since Panels do expose a Padding property, one technique would be to: Create a Panel Set its border to match a Textbox (e.g., Fixed3D) Set its background color to match a Textbox (e.g., White or Window)

Keyboard.Focus does not work on text box in WPF

半城伤御伤魂 提交于 2019-12-20 09:48:19
问题 I am banging my head on what looks like such a simple problem to fix in wpf but i have yet to discover why i can't get my app to behave according to my plan. I have a small search box that pops-up in my wpf application when user presses ctrl+f. All i want is for the caret to be flashing inside the search box text box, ready to take whatever user input without the user having to click on it. Here is the xaml code for the text box which is visible, enabled, hit testable, tabstopable and

Validating a Textbox field for only numeric input.

断了今生、忘了曾经 提交于 2019-12-20 09:45:15
问题 I have created a form-based program that needs some input validation. I need to make sure the user can only enter numeric values within the distance Textbox. So far, I've checked that the Textbox has something in it, but if it has a value then it should proceed to validate that the entered value is numeric: else if (txtEvDistance.Text.Length == 0) { MessageBox.Show("Please enter the distance"); } else if (cboAddEvent.Text //is numeric) { MessageBox.Show("Please enter a valid numeric distance"

Textbox using textmode password not showing text asp.net c#

淺唱寂寞╮ 提交于 2019-12-20 08:59:37
问题 I have a few buttons on a web form, and when the user clicks them they will update the the textbox. This worked till I added the textmode = password. Now the textbox doesn't show the text anymore. I debugged the app, and the text property is getting the value, but once again it is not showing. Here is what I have tried: protected void btn_punch_7_Click(object sender, EventArgs e) { const string string_punch_Number_7 = "7"; var text = txt_punch.Text; text += string_punch_Number_7; txt_punch

Press enter in textbox to and execute button command

跟風遠走 提交于 2019-12-20 08:49:17
问题 I want to execute the code behind my Search Button by pressing Enter . I have the Accept Button property to my search button. However, when i place my button as NOT visible my search doesn't execute. I want to be able to press Enter within my text box and execute my button while its not visible. Any suggestions would be great! Below is one attempt at my code in KeyDown Event if (e.KeyCode == Keys.Enter) { buttonSearch_Click((object)sender, (EventArgs)e); } 回答1: You could register to the

TextBox.TextChanged event firing twice on Windows Phone 7 emulator

无人久伴 提交于 2019-12-20 08:30:29
问题 I have a very simple test app just to play around with Windows Phone 7. I've just added a TextBox and a TextBlock to the standard UI template. The only custom code is the following: public partial class MainPage : PhoneApplicationPage { public MainPage() { InitializeComponent(); } private int counter = 0; private void TextBoxChanged(object sender, TextChangedEventArgs e) { textBlock1.Text += "Text changed " + (counter++) + "\r\n"; } } The TextBox.TextChanged event is wired up to

Dynamically add textbox in WPF

隐身守侯 提交于 2019-12-20 07:49:11
问题 I am creating a textbox dynamically. I have 2 columns in my grid. I want to add new textbox to the row if the other textbox value="tea". I want to create new textbox to corresponding row textbox value change. I am unable to use Tag to get selected row here. because I have already used Tag for some purpose. I don't have much idea about Tag. Anyhow, how can I add new textbox to the column1 to the corresponding row? This is my code.. public int count = 1; public TextBox txt1; private void btn

manipulating textbox variables in calculations

百般思念 提交于 2019-12-20 07:18:39
问题 I have some code where I am trying to use variables in a tabpage. The first tabpage only has one text box for user entry (miles.text) and a button to do a calculation: traveltime = mileage/speed. The value from miles.text is stored into a variable called mileage while the speed used is stored in a variable called speed (me.speedtextbox.text). Ordinarily, doing val(variable.text) works like a charm and it's not doing it in this case. When the user enters 100 for the mileage, it should be