Post by bobowk on Feb 28, 2017 17:07:34 GMT 10
Is my head screwed on tight ? I'm trying to check if the RichTextBox has selected https:// and nothing else. I tried: if (urlTextBox.SelectedText="https://") and if (urlTextBox.SelectedText.toString="https://")
but nothing works! Thanks for reading! If I find a solution I'll keep you updated Thanks!
|
|
Post by Imformas on Feb 28, 2017 17:40:46 GMT 10
Dunno weather you did that just on the post but every if statment must have a double == and for generic if statments something == something ? something : elsesomething; but other than that it looks correct man. :/
Programming language'sCSharpC++CObjective-CVBProject'sSharpMediaSharpEditYoutifygithub.com/Stephen-Fox-0
Last Edit: Feb 28, 2017 17:41:05 GMT 10 by Imformas
|
|
Post by Nathan Lecompte on Feb 28, 2017 19:20:37 GMT 10
What sub did you put the code in?
|
|
Post by Nathan Lecompte on Mar 1, 2017 15:29:43 GMT 10
What are you trying to achieve exactly? Are you trying to color the "https://" section of the text green?
If so you could do this (put this in the loadingComplete event or something similar):
If (urlTextBox.Text.Contains("https://")) { urlTextBox.Select(0, 8); urlTextBox.SelectionColor = Color.Green; urlTextBox.DeselectAll(); }
|
|
Post by bobowk on Mar 1, 2017 16:27:29 GMT 10
Nathan Lecompte There is a problem. The initial load, it works like a charm. But... If I click a link on any website the urlTextBox text turns all green....
Last Edit: Mar 1, 2017 16:35:25 GMT 10 by bobowk
|
|
Post by bobowk on Mar 1, 2017 16:28:22 GMT 10
Nathan Lecompte This is what is in my web_addresschanged this.Invoke(new MethodInvoker(() => { this.urlTextBox.Text = e.Address;
}));
|
|
Post by Nathan Lecompte on Mar 1, 2017 18:04:13 GMT 10
Oh right yes, forgot a couple lines - you need to change it to all black (or whatever the main ForeColor is) before changing it again, like this: urlTextBox.SelectAll(); urlTextBox.SelectionColor = Color.Black;
If (urlTextBox.Text.Contains("https://")) { urlTextBox.Select(0, 8); urlTextBox.SelectionColor = Color.Green; urlTextBox.DeselectAll(); } Otherwise it'll set the ForeColor to all of the text to that of the first character.
|
|
Post by bobowk on Mar 1, 2017 18:33:35 GMT 10
Nathan Lecompte I found a solution to this: private void web_addresschanged(object sender, AddressChangedEventArgs e) { this.Invoke(new MethodInvoker(() => { urlTextBox.SelectAll(); urlTextBox.SelectionColor = Color.FromArgb(64, 64, 64); urlTextBox.DeselectAll(); this.urlTextBox.Text = e.Address; if (urlTextBox.Text.Contains("https://")) { urlTextBox.Select(0, 5); urlTextBox.SelectionColor = Color.Green; urlTextBox.DeselectAll(); } }));
}
|
|