How to insert textbox between string( C# (Winform)? - c#

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");

Related

Add a new label with the inserted text when the text is inserted on my database on Xamarin Forms C#

I tried looking triggers up for mysql but from what I can tell its no use for me here. I would like the labels to be one on top of the other. I would appreciate some help
EDIT: Because what I want might not be clear,
Whenever I insert a text on my database I want to create a label on my application with the the text I just inserted. For example when I insert "username" I want a label to be created and have the Text value equal to username. Then when I insert "password" I want another label under it with the text = "password" and so on with a third and fourth label...

How To add * in Textbox Starting value and print into label in C#

I have some text boxes in my form where the user need to enter the different prices of article, what I want to do is to automatically add Starting value * whenever text is changed . So when the user types 1 it is displayed like *****1
and text box Length are 6 size fix. then again user type 111 it is display like ***111
Not sure if you are on web, forms or what, but here is what you looking for:
txt1.Text = txt1.Text.PadLeft(6, '*');
Reference: PadLeft
You can use the PadLeft method for a string:
textBox1.Text = textBox1.Text.PadLeft(6, '*');
See an example here: https://dotnetfiddle.net/GPfFsx

ASP.NET saving text to database in correct format

I have an ASP.net 4.5 text box with 5 rows. When I save the below data to my table it does not take in consideration that there are line breaks.
Example:
Hello my name is Mike!
How are you?
Please can you help?
When saving this data to my table it of course save it like this below and it will be displayed like this again if I populate my website with this value.
Hello my name is Mike!How are you?Please can you help?
But I want it to be displayed with the line breaks as the way it was written in the first place.
The thing is, I do not want to make use of a custom form item because then the user will be able to copy and paste all html from another website in and I do not want that.
Any idea how this can be done without using a plugin such as below where the user will be able to copy and paste data into?
To populate your text box from the database try;
TextBox1.Text = someText.Replace("\r\n", Environment.NewLine)
For Label
Label1.Text = someText.Replace("\r\n", <br />)
Alternatively you could save the data to your database with the
someText = TextBox1.Text.Replace("\r\n", "<br />")
Although this approach may not be appropriate if the database is also used elsewhere.

How to Insert (Append) Table into richTextBox Control

I am trying to generate a function to enable users to insert table into a richTextBox winForm control.What I have is a Insert button which is fireing an InsertForm winForm.The form contains two textboxes as txtRow and txtCol and a btnInsert.
Now, I would like to know is there any way which I append the table in the position of cursor?
Can you please help me to figure this up?
Thanks for your time in advance
You can use RTF to allow tables. According to SelectedRtf documentation, if nothing is selected then the RTF string is inserted at the current point.
myRichTextBox.SelectedRtf = RTFtablestring;

How to display data inside a textbox?

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();

Categories

Resources