• 0

[C#] WebBrowser control


Question

Hey guys, I've found tutorials on the WebBrowser control on changing font size and stuff (on the subject of making a basic wysiwyg). But I need slightly more then that and I can't find anything anywhere so far on how to make a table button to dynamically create tables and control the rows and columns. This would be very helpful. Any ideas?

Link to comment
https://www.neowin.net/forum/topic/641108-c-webbrowser-control/
Share on other sites

3 answers to this question

Recommended Posts

  • 0
  sathenzar said:
Hey guys, I've found tutorials on the WebBrowser control on changing font size and stuff (on the subject of making a basic wysiwyg). But I need slightly more then that and I can't find anything anywhere so far on how to make a table button to dynamically create tables and control the rows and columns. This would be very helpful. Any ideas?

Look at the documentation for the HtmlDocument class. They give an example of how to manipulate the doc programmatically.

http://msdn.microsoft.com/en-us/library/sy...mldocument.aspx

  • 0

ok, so I have everything working, however this control is by far the most annoying control to work with. I just want to dynamically add php code before the HTML part, so I simply do a string mTxt = "<?php ?>" + WebBrowser.DocumentText; and it all the sudden calls the documentcompleted event twice and on top of that get this, the first time it gets called, it inserts all the code needed, the second time it erases all the php code from the page. WHY??!?!! It's driving me crazy:

		void gl_wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
		{
			//if (exeI != 2)
		   // {
				initEnv();
				exeI++;
		   //}
		}

		public void initEnv()
		{
			//if (exeI == 0)
		   // {
				exeI = 1;
				this.doc = (mshtml.IHTMLDocument2)gl_wb.Document.DomDocument;
				divCol = gl_wb.Document.GetElementsByTagName("div");
				tdCol = gl_wb.Document.GetElementsByTagName("td");
				tblCol = gl_wb.Document.GetElementsByTagName("table");
				doc.designMode = "On";
				for (int i = 0; i &lt; tdCol.Count; i++)
				{
					tdCol[i].Style = "border: 1px dotted #2a2a2a;";
				}

				for (int i = 0; i &lt; tblCol.Count; i++)
				{
					tblCol[i].Style = "border: 1px dotted #2a2a2a;";
					tblCol[i].Click += new HtmlElementEventHandler(tblClick);
				}

				AddCons();
			//}
		}

My main file I call this code:

 using (StreamReader sr = new StreamReader(@".\tmp\" + page.PageGuid + ".html"))
				{
					wb.DocumentText = sr.ReadToEnd();
					sr.Close();
					sr.Dispose();
				}
				webL.initEnv();

One strange thing I noticed if I don't include the webL.initEnv() in the main file it doesn't work at all.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Lol I heard this last night and I about fell out of my chair. I rebooted again just to be sure I wasn't hearing things.
    • Microsoft accidentally replaced Windows 11 startup sound with one from Vista by Taras Buria The recently released Windows 11 Dev and Beta builds introduced some welcome changes and improvements. However, those preview builds are not flawless and have a pretty long list of known issues. One of those issues, though, is a rather delightful one: Windows 11's default startup jingle has been accidentally replaced with one from 2006. After Windows Insiders discovered that Windows 11 now plays the Windows Vista startup sound and reported it to Microsoft, the company acknowledged it and added it to the list of known bugs in the latest Windows 11 Dev and Beta builds: This week’s flight comes with a delightful blast from the past and will play the Windows Vista boot sound instead of the Windows 11 boot sound. We’re working on a fix. Although Windows Vista is nearly two decades old, it was brought to everyone's attention this week after Apple introduced macOS 26 Tahoe with its controversial "Liquid Glass" redesign, which many consider a rather miserable remix of Windows Aero from Windows Vista and Windows 7. While it is definitely an interesting coincidence, Microsoft did not intentionally replace the startup sound in Windows 11 preview builds. Brandon LeBlanc from the Windows Insider team confirmed in his X that that is a bug after joking about everyone talking about Windows Vista once again in light of Apple's latest announcements: It is worth noting that if you miss the startup sound of Windows Vista, you can still use it in modern Windows versions. All it takes is the original WAV file and a few clicks in the Windows Registry and Sound settings. And for those who want a shot of nostalgia, here is the sound of Windows Vista startup: What startup jingle do you like more: Windows Vista or Windows 11? Share your thoughts in the comments.
    • I refused at $70, $60 was cutting it close for me and I only bought one game at that price, CP2077.
    • Markets are always a follow the leader type of place so to speak. MS didn't raise prices first, but after everyone else did, they will to. Besides, at least they're doing other pro-consumer moves like Play Anywhere. In this case, you can think of it as $80 for 2 copies (console and PC) while Sony and Nintendo would just charge you for both, so $160. Regardless who does it, $80 is too much, even $70 is IMO. Lots of games still come out at $50 and sell well, even if your budget is higher, at $50 the odds are you'll sell more copies and just make it up on volume.
    • How about letting us do an in place upgrade from recovery that would be amazing.
  • Recent Achievements

    • Apprentice
      Wireless wookie went up a rank
      Apprentice
    • Week One Done
      bukro earned a badge
      Week One Done
    • One Year In
      Wulle earned a badge
      One Year In
    • One Month Later
      Wulle earned a badge
      One Month Later
    • One Month Later
      Simmo3D earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      558
    2. 2
      ATLien_0
      258
    3. 3
      +FloatingFatMan
      181
    4. 4
      Michael Scrip
      124
    5. 5
      Steven P.
      97
  • Tell a friend

    Love Neowin? Tell a friend!