My question is that I have extracted data from a file and pushed into a string variable.
I have a FORM created in visual studio having a text box, so I want to display that extracted data in textbox created.
How can achieve this?
You can do it like this:
yourTextBox.Text = yourString;
For a TextBox, it is just
myTextBox.Text = myStringVariable;
But if the data is large, you may want to consider the RichTextBox control instead.
This is all assuming you're using Windows Forms...
string strName="someone";
TextBox1.Text=strName;
If you trim the data to remove the unwanted trailing spaces if there is any.
TextBox1.Text=strName.Trim();
Related
I have to insert textbox between the string.
Is there any way to dynamically create textbox and then inject textbox in between string in C# Winforms. Here the screenshot, That shows what I am trying to do.
enter image description here
chbInform.Text = chbInform.Text.Replace("#", "textBox");
Or I didn't understand ur question...
If you want to just replace the values # with some other strings, the better way would be to change your chbInform.Text to following string:
"We will start taking order from {0} to {1}, Sorry for the inconvenience."
This way, you will be able to set these placeholder values to any other values like so:
chbInform.Text = string.Format(chbInform.Text, "your_first_value", "your_second_value");
I am trying to use CKEditor into my ASP.NET Application. I got a good resource as follows
http://www.codeproject.com/Tips/532164/How-to-Integrate-CKEditor-with-ASP-NET
http://www.codeproject.com/Tips/455129/Rich-Text-Editor-with-ASP-NET
I want to set the CKEditor Text without losing its formatting (bold, Italics etc..) into a multiline Textbox. So, I am trying the following code.
string str = this.CKEditor1.Text;
TextBox1.Text = str;
Thus its giving me a html encoded Output as follows
<p>dfgdfgfdgdfgdfgdf<strong>gdf</strong></p>
But I don't want to have those tags around but formatting should be preserved. I tried using HTMLEncode and HTMLDecode, Also used this.CKEditor1.HtmlEncodeOutput = false; but of no avail.
Is there any other way I can save the text as it is without losing formatting into my Textbox?
I know textboxes are not meant for storing formatted html outputs but I have to store this(Comments) along with a formatting in a text box(for History) in my Application. Previously they were using Plain text boxes for both comments and History. Now richtext editing is needed and hence we are tying to go this way. Any other good approaches and suggestions are most welcome.
No, a Textbox cant display formatted values. That is why you have the CKEditor.
You can still store the html formated values in the database and display them (formatted) in for example a Label
There is a richTextBox that has string. I want to select a few characters on the richTexBox by mouse and save them in a variable. I use this method:
richTextBox1.SelectedRtf;
It shows me selected characters but is has some additional string and i don't want them. How can I remove them?
This is additional string:
{\rtf1\fbidis\ansi\ansicpg1256\deff0\deflang1065\uc1 }
try
richTextBox1.SelectedText
Here is the msdn link for more information
http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.selectedtext(v=vs.110).aspx
Selection.Text property will return the selected text of Rich Edit Text box.
richTextBox1.Selection.Text
RichTextBox.SelectedText? may be?
http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.selectedtext(v=vs.110).aspx
use this
richTextBox1.SelectedText (property)
I entered the text "J&K"(Without Cotes) in my StateCode textbox and saved it into database(SqlServer). But it saved as J & amp; K. So m not able to fetch the data saved, with J&K(Primery key). How can I disable encoding of text before saving it to database?
You can use the HttpUtility.HtmlDecode Method to remove the encoding.
Use Server.HtmlEncode("YourTextWith<and>Characters") for this activity.
wrap your output text within it.
Or,
This can also be helpfull>>
System.Web.UI.HtmlControls.HtmlTextArea textBox = new System.Web.UI.HtmlControls.HtmlTextArea();
textBox.Value = "j&k";
Hope its helpful.
I have some text coming from database in a Multiline textbox, how can I copy that to the clipboard so that the user can paste it into another window or file (e.g. from my application to another textbox)? OR to notepad/word file if possible.
Clipboard.Clear(); //Clear if any old value is there in Clipboard
Clipboard.SetText("abc"); //Copy text to Clipboard
string strClip = Clipboard.GetText(); //Get text from Clipboard
There is no difference in copying text from a single or multiline TextBox to and from the clipboard using Clipboard.SetText() (and of course Clipboard.GetText()). A TextBox will still contain a single String, whether it contains line breaks or not. That's only eye candy.
From a limitations perspective, your ClipBoard.SetText() method will always only accept one single string as well, its size only limited by and to the amount of free memory at that given time.
No special code is needed to paste this text manually into applications like Notepad or Word.
Clipboard.SetText(yourTextBox.Text); is all you need.
For saving lines in text you should replace "\n" to NewLine character, as in example:
string textforClipboard = TextBox1.Text.Replace("\n", Environment.NewLine);
Clipboard.Clear();
Clipboard.SetText(textforClipboard);
System.Windows.Forms.Clipboard.SetText(..)
http://msdn.microsoft.com/en-us/library/system.windows.forms.clipboard.settext.aspx