textbox

.NET TextBox - Handling the Enter Key

强颜欢笑 提交于 2020-01-09 05:27:04
问题 What is definitively the best way of performing an action based on the user's input of the Enter key ( Keys.Enter ) in a .NET TextBox , assuming ownership of the key input that leads to suppression of the Enter key to the TextBox itself (e.Handled = true)? Assume for the purposes of this question that the desired behavior is not to depress the default button of the form, but rather some other custom processing that should occur. 回答1: Add a keypress event and trap the enter key

How to write textbox values to .txt file with vb.net

被刻印的时光 ゝ 提交于 2020-01-09 03:35:50
问题 I have a simple form with two textboxes, I want Textbox1 to write to a file named C:\VALUE1.txt and Textbox2 to write its value to a file named C:\VALUE2.txt Any text that is already in the text file MUST be over written. 回答1: It's worth being familiar with both methods: 1) In VB.Net you have the quick and easy My.Computer.FileSystem.WriteAllText option: My.Computer.FileSystem.WriteAllText("c:\value1.txt", TextBox1.Text, False) 2) Or else you can go the "long" way round and use the

How do I fill an empty textbox with default text?

你离开我真会死。 提交于 2020-01-09 03:20:21
问题 How do I fill a textbox with text if it is empty? I am using VB.NET. 回答1: It looks like you're describing a cue banner , which is prompt text that is displayed in an empty textbox. As of Windows XP, this functionality is natively supported by the operating system. The effect achieved doing it this way is much more elegant than setting the default text yourself in the TextChanged event. It looks like this: Setting this up is accomplished at the level of the Windows API by sending the textbox

Adapt windows messages in this class

一曲冷凌霜 提交于 2020-01-07 08:27:06
问题 I would like to know if this code can be adapted to use it inside a normal class (Example: Form1 Class) to don't need subclassing a Control. Code is from BlueMonkMN here Capture the option selected by the user in a windows default contextmenu? Class MyTextBox : Inherits TextBox Public Enum ContextCommands WM_CUT = &H300 WM_COPY = &H301 WM_PASTE = &H302 End Enum Public Class ContextCommandEventArgs Inherits EventArgs Public Property Command As ContextCommands End Class Event OnCut(sender As

Add Label with Textbox at design time

走远了吗. 提交于 2020-01-07 05:30:48
问题 I am creating a project using VS.NET (C#) with many forms that contain textboxes and associated labels. I have created the association through an exposed property I created for the textbox which contains the label name. The problem is that each time I add a textbox at design-time I have to add a label and then enter the label name into the property of the textbox. I would much rather do this dynamically at design-time when I create the textbox, much like the old VB textbox add. I have been

C# check characters in clipboard when paste into textbox

不羁的心 提交于 2020-01-07 04:32:25
问题 Are there some ways to check charater in clipboard only digit before paste into textbox C# (Both Ctrl+V and right click -> Paste), which not using MarkedTextbox. 回答1: I ~think~ you want a TextBox that can only accept digits? If yes, then set the ES_NUMBER style on the TextBox via SetWindowLong(): public partial class Form1 : Form { public Form1() { InitializeComponent(); this.Load += Form2_Load; } private void Form1_Load(object sender, EventArgs e) { SetNumbersOnlyTextBox(this.textBox1); }

How do I open a file into a textbox with multiple tabs?

三世轮回 提交于 2020-01-07 03:07:08
问题 I'm creating a document writing program in VB.NET, and I can create multiple tabs. How would I open a file into the textbox that I am open on, even though I can't declare what textbox I'm using? Link to understand this better Code for the sub: Public Sub setText(Byval value As String) If tabPage1.Visible = True Then mainText.Text = value ElseIf tabPage2.Visible = True Then textBox1.Text = value End If End Sub Thanks in advance! 回答1: You need to use the same type of idea you did for the

Excel change text box color based on value

ぃ、小莉子 提交于 2020-01-06 19:03:56
问题 I need to change the background color of a text box based on the value in that box which is being retrieved from another page. As I am finding out, you cannot do conditional formatting with text boxes, so the only way is with VBA. I cannot for the life of me figure out how to set up the code to make this work. I tried opening the VBA viewer and using this code: Private Sub TextBox1_Change() If TextBox1.Value = "" Or Not "1" Or Not "2" Or Not "3" Then _ TextBox1.BackColor = RGB(0, 0, 0) If

How to fill datagridview a “-” delimited text from a richtextbox

时光总嘲笑我的痴心妄想 提交于 2020-01-06 18:14:03
问题 How can i fill my datagridview with a - delimited text from my richtextbox? example: my richtextbox content: 000001-Kobe-Bryant-24-Lakers 000002-Lebron-James-23-Cavaliers 000003-Derick-Rose-1-Bulls 000004-Kevin-Durant-35-Thunders Then the out put on my datafridview should be like this PlayerID | Name | LastName | Number | Team | ------------------------------------------------------------------- 000001 |Kobe | Bryant | 24 |Lakers | -------------------------------------------------------------

How to fill datagridview a “-” delimited text from a richtextbox

隐身守侯 提交于 2020-01-06 18:13:21
问题 How can i fill my datagridview with a - delimited text from my richtextbox? example: my richtextbox content: 000001-Kobe-Bryant-24-Lakers 000002-Lebron-James-23-Cavaliers 000003-Derick-Rose-1-Bulls 000004-Kevin-Durant-35-Thunders Then the out put on my datafridview should be like this PlayerID | Name | LastName | Number | Team | ------------------------------------------------------------------- 000001 |Kobe | Bryant | 24 |Lakers | -------------------------------------------------------------