Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have made replace function, but I am really struggling to make "Replace All"
function.
I tried to make into for loop but that didn't work well...
I have dialog box just like in usual Notepad (another form) and i have richtextbox in Main form. Any ideas how can I make it?
You can simply use the String.Replace method:
private void DoReplace(string SearchFor, string ReplaceWith)
{
RichTextBox1.Text = RichTextBox1.Text.Replace(SearchFor, ReplaceWith);
}
Call this function and supply the string you want to search for in Richtextbox1 (or whatever it is called in your case) as the first parameter and the replacement as the second parameter.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have this error and I have no ideo about what should I do
The aim is when I click to button, it should read the word in textbox and save it into the string variable by its new factor.I have the error oin the topic
private void panel_button_kelimeekle_kaydet_Click(object sender, EventArgs e)
{
if(panel_checkbox_ing.Checked)
{
string (panel_textbox_kelimeekle_yab.Text) = Ingkelimeler[(Ingkelimeler.Length+1)];
}
}
If panel_textbox_kelimeekle_yab is already a textbox on your form, then you don't need to declare its type when you assign a value to it. C# thinks you're trying to declare a new string variable.
Change that line of code to
panel_textbox_kelimeekle_yab.Text = Ingkelimeler[(Ingkelimeler.Length+1)];
This probably won't solve all your problems, but at least it will get you on to the next error message. (You probably mean Length-1 in your array index, but there's really no way for us to know.)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I though it was simple. but I didn't manage to make this line of code add "\Game_Progress.xml" to my String
code_file.Insert(code_file.Length, "\\Game_Progress.xml");
You can append the string using the += operator:
code_file += "\\Game_Progress.xml";
Note: If you want to combine a path, you should consider using the Path Combine method:
System.IO.Path.Combine(code_file, "\\Game_Progress.xml")
C# can require an #prior to the string when using backslashes. Try:
code_file.Insert(code_file.Length, #"\\Game_Progress.xml");
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
when I put a breakpoints on my textbox it shows textbox.length = "" even if there are characters in the textbox
There is no Length property present in TextBox Class.
Probably you mean to Check the Length on Textbox Text property which is of string type.
textbox.Text.Length
More info about the code would be nice. Is your Textbox really enabled? No transparent layer in front of it? You used the mySQL-Tag. Does that mean you use some kind of binding in textbox? Possibly you can't change the content of your textbox, because the database-binding / connection is read-only?
Is there really some textbox.length property?? Are you sure you are referring to the right property? Try this:
Convert.ToString(textBox1.TextLength)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a class library to add a customized toolbox to a external IE browser.
I'm using SHDocVw to do the back/forward buttons (e. g.). My question is, sense this is multilingual, how can I change the buttons text...
The url give me "/en/" or "/ar/", how can i catch this?
Thanks
With the Mati Cicero answer I managed to do it.
string page = ie.LocationURL;
Regex rgx = new Regex(#"https?://[a-zA-Z0-9.-_]+(/((?'lang'ar|en)|.*))/?");
var lang = rgx.Match(page).Success ? rgx.Match(page).Groups[1].Value : "ar";
You can try the following regex, I tried to make it as much generic as I could:
https?:\/\/[a-zA-Z0-9\.\-_]+(\/((?'lang'es|en)|.*))\/?
You would then examine the group "lang" to see if a match was made.
You would aso like to add more available languages (Added ch and in):
https?:\/\/[a-zA-Z0-9\.\-_]+(\/((?'lang'es|en|ch|in)|.*))\/?
If its always the first directory;
var lang = new Uri("http://sitename.com/en/pages/default.aspx")
.Segments[1].Replace("/", string.Empty).ToLower();
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
In my current project I want to implement a checkbox that, if checked, replaces all strings in labels, tabs, etc. currently being shown on a form with a different string.
For example, If checked, all instances of the word "car" would change to the word "truck" all through out the program.
I'd rather not go through a do a .replace on every single string in the code. I was wondering if there was some way to "intercept" output strings and replace them on the fly; something like making a string-listener. Any help would be appreciated!
I am no GUI/WinForms program but this would be my personal approach. Add all of these UI elements to a List<T> in the forms constructor. Then in the "replace box checked event handler" you can just iterate over the list applying the same change to all the items. It's by no means a perfect solution but it does mean you only have to statically reference each of the items once. After they're in the list you can operate on all of them very easily.