Is there a way to control the content in one webBrowser control from another webBrowser control in a different window? I want to have HTML in one, then by clicking, or doing something in there, control or modify, or whatever, the content in the other window's webBrowser control. I would assume that the content being controlled would need to be in an owned window... Any thoughts? Thanks...
simplicitylabs
Posts
-
Control content in one webBrowser control from another... -
Reading USB IDThere is indeed a class that returns this type of info. A most excellent gentleman by the name of Dan helped me out with this a while back. He has made a very simple to use class for this very purpose. http://www.cfdan.com/posts/Retrieving_Non-Volatile_USB_Serial_Number_Using_C_Sharp.cfm
-
Experiment -- Looking for suggestionsWhile this may not be best practice, it's experimental in my attempts to learn regex while playing around with a RichTextBox. The idea is to find all HTML tags and color them. However, it's not behaving well. It does indeed find tags such as <html> or </html>, but not <body bgcolor="#ffffff">. I'm relatively sure I have the Regular Expression correct. Another strange behavior is it won't let me edit the colored tags once they have been "colorized". I'm triggering this with a key press event (Enter). At this point, I'm open to suggestions to make this work as prescribed, and of course, I'm prepared to hear alternative suggestions to get the results I'm looking for. Thank you...
private void ChangeTagColors(RichTextBox richTextBox1) { richTextBox1.SelectionStart = 0; richTextBox1.SelectionLength = richTextBox1.Text.Length; int index = 0; foreach (string str in richTextBox1.Text.Split()) { Regex regex = new Regex( @"(\\<\[^\\>\]\*\\>)", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.ExplicitCapture | RegexOptions.Compiled ); if (regex.IsMatch(str)) { richTextBox1.SelectionColor = Color.Blue; richTextBox1.SelectionProtected = true; } index = index + str.Length + 1; } }
-
Regular Expressions...I'm sorry, I asked the wrong question. I actually need to find the entire tag, including the < and >.
-
Regular Expressions...I'm having trouble getting my head around regular expressions. How do I find anything between < and > ? Thank you.
-
Lock a textbox and richtextbox togetherAh, ok...I misunderstood what you were asking. See the code below that creates the line numbers in textbox1: Here's the code that does the work:
private void updateNumberList() { Point pos = new Point(0, 0); int firstIndex = richTextBox1.GetCharIndexFromPosition(pos); int firstLine = richTextBox1.GetLineFromCharIndex(firstIndex); pos.X = ClientRectangle.Width; pos.Y = ClientRectangle.Height; int lastIndex = richTextBox1.GetCharIndexFromPosition(pos); int lastLine = richTextBox1.GetLineFromCharIndex(lastIndex); pos = textBox1.GetPositionFromCharIndex(lastIndex); textBox1.Text = ""; for (int i = firstLine; i <= lastLine; i++) { textBox1.Text += i + 1 + " \\r\\n"; } }
Here's the code that calls it:
private void richTextBox1\_TextChanged(object sender, EventArgs e) { updateNumberList(); }
-
Lock a textbox and richtextbox togetherI haven't written any code for "locking" the two together. I have searched for relevant code snippets and ideas to do this, but haven't found any. I'm not asking anyone to write it for me -- I can't learn this stuff if every time I need help someone just does it for me. I just need some pointers. Thanks...
-
Lock a textbox and richtextbox togetherIf that makes any sense... I have a textbox to the left of a richtextbox. The textbox displays line numbers of the richtextbox. As you type into the richtextbox, line numbers appear in the textbox. If you type beyond the limits of the form, the numbers continue to roll with the flow, so to speak. However, if you scroll back up in the richtextbox, the textbox doesn't follow. How can I lock the two together so they move with each other up or down?
-
dumbed down auto indent/smart indentOne for the "duh" files. I figured out why it wasn't working for me. I hadn't added the KeyPress event to my richTexBox control. Thanks for your patience and help.
-
dumbed down auto indent/smart indentI'm using Vista Home Premium, Visual Studio 2005 and .Net 3.0.
-
dumbed down auto indent/smart indentI placed the code into a new project with nothing but the form and the richTextBox. It still didn't work. There are no errors, however, when I run the app nothing happens when I hit Enter -- I.E. no spaces and/or tabs are added before the cursor on the next line. Is there another way to do this?
-
dumbed down auto indent/smart indentJudging from your concise and confident reply, I have to assume you tested your suggestion. That being said, if it's still not working for me after I made your suggested modifications, what am I doing wrong? Could the TextChanged event be interfering? Thank you for your help.
private void RichTextBox1\_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Enter) { e.Handled = true; int pos = RichTextBox1.SelectionStart; int lineNumber = RichTextBox1.GetLineFromCharIndex(pos - 1); String currentLineStr = RichTextBox1.Lines\[lineNumber\]; int firstChar = 0; while (firstChar != currentLineStr.Length) { if (!Char.IsWhiteSpace(currentLineStr\[firstChar\])) break; firstChar++; } String indent = currentLineStr.Substring(0, firstChar); RichTextBox1.SelectedText = indent; } }
-- modified at 1:23 Saturday 26th May, 2007
-
dumbed down auto indent/smart indentI have torn the Web apart looking for a solution. The only thing I have found that makes any sense, doesn't work for me. I want to hit the Enter key, read the previous line (the line the cursor just left) and determine how many spaces and/or tabs are before the first character. Then, place the cursor at the same position on the current/new line by adding the correct number of spaces and/or tabs before it including the tabs and/or spaces that may or may not already be there. I know there are controls/classes for sale out there that offer all the cool stuff for smart indenting and syntax highlighting, but I'm not a wealthy man.
private void richTextBox1\_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Enter) { e.Handled = true; int pos = richTextBox1.SelectionStart; int lineNumber = richTextBox1.GetLineFromCharIndex(pos); String currentLineStr = richTextBox1.Lines\[lineNumber\]; int firstChar = 0; while (firstChar != currentLineStr.Length) { if (!Char.IsWhiteSpace(currentLineStr\[firstChar\])) break; firstChar++; } String indent = currentLineStr.Substring(0, firstChar); richTextBox1.SelectedText = indent; } }
Thanks in advanced for any help... (I may be asking about syntax highlighting after I get this part worked out, if I can't figure it out.)
-
Access denied...Even if the file doesn't exist yet? If that's the problem, boy do I feel like an idiot.
-
Access denied...Nope. Not write protected. I'm wondering, in the code I'm opening StreamWriter, but not actually writing anything yet. Could this be the problem?
-
Access denied...I'm attempting to write a file to a removable drive. When the app gets to the point where it creates the StreamWriter, it's stops and tells me access to the *whatever*:\ drive denied. I have administrator rights, and have also given the app admin rights by "running as admin". Is there something I should be doing besides the usual to get this working? Is what I'm doing correct?
private void button1\_Click(object sender, EventArgs e) { string usbDriveLetter = listBox1.SelectedItem.ToString(); string sPath = usbDriveLetter; sPath = usbDriveLetter.ToString(); StreamWriter sw = new StreamWriter(sPath); ...and so on
Thank you for your input.
-
Escape characters in resource stringsIs article this helpful at all? http://www.awprofessional.com/articles/article.asp?p=25322&seqNum=6&rl=1
-
Second window behaviorThat was it. Thank you very much.
-
Second window behaviorI have Form, and with a button, it launches a second form. I want the second form to "stay with" the first form. On top of it, in fact. But, not on top of everything else. Does any of this make sense? This is not MDI... I've exhausted Google -- it's tired of me search for different variations of "form, window, child, parent, etc...". Thoughts?
-
inserting textbox values into datagridview