English 中文(简体)
选择文本框.. 窗口窗体应用程序中以双引号写入的文本
原标题:Selecting the text written in double quotes in textbox.. windows form application
  • 时间:2012-05-26 14:03:13
  •  标签:
  • c#
  • winforms

i am sorry bu i am new to c# and need to learn a lot :( can u people help me by telling how can i select the text written in quotes in richtextbox? like if i writ in richtextbox on debugging the program

        cout<<"HELLO WORLD"; 
        HELLO WORLD= new array

HELLO World应该储存在一个新的阵列/字符串中

最佳回答

如果您确实在与 c# 合作(而不是 c++, 我认为你是), 您可以做以下工作 :

  string  input = TextBox1.Text; //<--- replace Textbox1 with whatever you called your textbox
  string[] txtWithNoQuotes = input.Split( " );
  string noQuotes = txtWithNoQuotes[1]; // <-- this will give you Hello world, without the quotes

编辑: 编辑: 认为我有点搞错了问题, 如果您只是想要文本框中输入的文本, 简单做

string input  = NameOfYourTextbox.Text;
问题回答

s让我们说您的 RichTextBox 的名称是 RichTextBox1; 然后在文本框中设置值( 您应该将此写入文件后面的代码; 如果您的表格被命名为 Form1, 那么您应该将此写入 Form1. cs ):

string s = RichTextBox1.Text;

要在 RichTextBox1 中选择引用的文字, 您需要这样的文字 :

string s = RichTextBox1.Text;
int f = s.IndexOf( " ), l = s.LastIndexOf( " );
if(f != l)
{
  RichTextBox1.Select(s, l - s + 1);
}




相关问题
Bring window to foreground after Mutex fails

I was wondering if someone can tell me what would be the best way to bring my application to the foreground if a mutex was not able to be created for a new instance. E.g.: Application X is running ...

How to start WinForm app minimized to tray?

I ve successfully created an app that minimizes to the tray using a NotifyIcon. When the form is manually closed it is successfully hidden from the desktop, taskbar, and alt-tab. The problem occurs ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

Handle DataTable.DataRow cell change event

I have a DataTable that has several DataColumns and DataRow. Now i would like to handle an event when cell of this DataRow is changed. How to do this in c#?

Apparent Memory Leak in DataGridView

How do you force a DataGridView to release its reference to a bound DataSet? We have a rather large dataset being displayed in a DataGridView and noticed that resources were not being freed after the ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

WPF-XAML window in Winforms Application

I have a Winforms application coded in VS C# 2008 and want to insert a WPF window into the window pane of Winforms application. Could you explain me how this is done.

热门标签