Archive for the ‘c#’ Category

Converting String to Single in C#

Some time ago, I needed to get Flash Movie sizes inside of my C# code. I googled and I found some great examples of how I can do it. It was Mike Swanson’s example project called FlashTools. I downloaded it and stated to use. While I was using this code I found a little bug that was occured depending of regional settings in the system. An error occured when FlashTools library tryed to convert String to Single. When I used English locale everything was going OK but when I changed the locale I got “Input string was not in a correct format”. A fix was very simple, I just passed the InvariantCulture as the second parameter of Convert.ToSingle method.
Read the rest of this entry »

Setting HTML for WebBrowser in C#

Today I tryed to insert HTML for WebBorwser in C#. I thought it’s a simple task. But when I tryed to use DocumentText property I got “<HTML></HTML>”. Then I tryed Document.Write("...") and I got that Document is null. After these tries I started to find out the easiest way to fill the WebBrowser with HTML without writing to disk and navigating the written file. Here is my code:

WebBrowser browser = new WebBrowser();
 
browser.Navigate("about:blank");
browser.Document.Write("<html><body>...</body></html>");

When the WebBrowser has been made, the Document object is null. So, we should call Navigate() method to get Document available.

If You have Your way to fill the WebBrowser with HTML I’m expecting for Your comments :)

Search
Categories
Archives

You are currently browsing the archives for the c# category.

Advertisement
Artisteer - Web Design Generator