Multiline Textbox with automatic vertical scroll

According to this question: TextBox.ScrollToEnd doesn’t work when the TextBox is in a non-active tab You have to focus the text box, update the caret position and then scroll to end: Status.Focus(); Status.CaretIndex = Status.Text.Length; Status.ScrollToEnd(); EDIT Example TextBox: <TextBox TextWrapping=”Wrap” VerticalScrollBarVisibility=”Auto” AcceptsReturn=”True” Name=”textBox”/>

Redirect console output to textbox in separate program

This works for me: void RunWithRedirect(string cmdPath) { var proc = new Process(); proc.StartInfo.FileName = cmdPath; // set up output redirection proc.StartInfo.RedirectStandardOutput = true; proc.StartInfo.RedirectStandardError = true; proc.EnableRaisingEvents = true; proc.StartInfo.CreateNoWindow = true; // see below for output handler proc.ErrorDataReceived += proc_DataReceived; proc.OutputDataReceived += proc_DataReceived; proc.Start(); proc.BeginErrorReadLine(); proc.BeginOutputReadLine(); proc.WaitForExit(); } void proc_DataReceived(object sender, DataReceivedEventArgs e) … Read more

textbox.Focus() not working in C#

Use Select() instead: recipientEmail_tbx.Select(); Focus is a low-level method intended primarily for custom control authors. Instead, application programmers should use the Select method or the ActiveControl property for child controls, or the Activate method for forms. http://msdn.microsoft.com/en-us/library/system.windows.forms.control.focus.aspx

Press enter in textbox to and execute button command

You could register to the KeyDown-Event of the Textbox, look if the pressed key is Enter and then execute the EventHandler of the button: private void buttonTest_Click(object sender, EventArgs e) { MessageBox.Show(“Hello World”); } private void textBoxTest_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { buttonTest_Click(this, new EventArgs()); } }

How can I format a decimal bound to TextBox without angering my users?

Try to resolve that on ViewModel level. That it: public class FormattedDecimalViewModel : INotifyPropertyChanged { private readonly string _format; public FormattedDecimalViewModel() : this(“F2”) { } public FormattedDecimalViewModel(string format) { _format = format; } private string _someDecimalAsString; // String value that will be displayed on the view. // Bind this property to your control public string … Read more

How to know if the text in a textbox is selected?

The following will tell you whether or not all of the text is selected within a text input in all major browsers. Example: http://www.jsfiddle.net/9Q23E/ Code: function isTextSelected(input) { if (typeof input.selectionStart == “number”) { return input.selectionStart == 0 && input.selectionEnd == input.value.length; } else if (typeof document.selection != “undefined”) { input.focus(); return document.selection.createRange().text == input.value; … Read more