<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Vacheslav Starikov&#039;s &#187; c#</title>
	<atom:link href="http://starikovs.com/cat/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://starikovs.com</link>
	<description>BLOG</description>
	<lastBuildDate>Wed, 21 Dec 2011 19:37:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>How to return a value form Event in C#</title>
		<link>http://starikovs.com/2011/07/15/how-to-return-a-value-form-event-in-c/</link>
		<comments>http://starikovs.com/2011/07/15/how-to-return-a-value-form-event-in-c/#comments</comments>
		<pubDate>Fri, 15 Jul 2011 11:00:51 +0000</pubDate>
		<dc:creator>Vacheslav</dc:creator>
				<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://starikovs.com/?p=523</guid>
		<description><![CDATA[public delegate bool MyEventHandler&#40;object sender /* additional params */&#41;; public event MyEventHandler MyEvent; &#160; public void MyMethod&#40;&#41; &#123; if &#40;MyEvent != null &#38;&#38; MyEvent&#40;this&#41;&#41; &#123; /* TODO: do something */ &#125; &#125; &#160; public void MyBind&#40;&#41; &#123; MyEvent += new MyHandler&#40;this&#41;; &#125; &#160; private bool MyHandler&#40;object sender&#41; &#123; return true; &#125;]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">delegate</span> <span style="color: #6666cc; font-weight: bold;">bool</span> MyEventHandler<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender <span style="color: #008080; font-style: italic;">/* additional params */</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">event</span> MyEventHandler MyEvent<span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> MyMethod<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>MyEvent <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">&amp;&amp;</span> MyEvent<span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #008080; font-style: italic;">/* TODO: do something */</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> MyBind<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    MyEvent <span style="color: #008000;">+=</span> <span style="color: #008000;">new</span> MyHandler<span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">bool</span> MyHandler<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://starikovs.com/2011/07/15/how-to-return-a-value-form-event-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Observer pattern example in C#</title>
		<link>http://starikovs.com/2011/03/11/observer-pattern-example-csharp/</link>
		<comments>http://starikovs.com/2011/03/11/observer-pattern-example-csharp/#comments</comments>
		<pubDate>Thu, 10 Mar 2011 21:25:19 +0000</pubDate>
		<dc:creator>Vacheslav</dc:creator>
				<category><![CDATA[c#]]></category>
		<category><![CDATA[patterns]]></category>

		<guid isPermaLink="false">http://starikovs.com/?p=460</guid>
		<description><![CDATA[This article has a simple sample of using Observer pattern. The description of this pattern you can read in other resources or you can understand the basis of the pattern exploring this example. Also, you can download an example in C#. This pattern is also known as Dependents pattern or Publish-Subscribe pattern class Subject &#123; [...]]]></description>
			<content:encoded><![CDATA[<p>This article has a simple sample of using <strong>Observer</strong> pattern. The description of this pattern you can read in other resources or you can understand the basis of the pattern exploring this example. Also, you can <a href="http://starikovs.com/my-examples/ObserverPatternExampleCSharp.zip">download</a> an example in C#. This pattern is also known as <strong>Dependents</strong> pattern or <strong>Publish-Subscribe</strong> pattern</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #6666cc; font-weight: bold;">class</span> Subject
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> List<span style="color: #008000;">&lt;</span>Observer<span style="color: #008000;">&gt;</span> observers <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> List<span style="color: #008000;">&lt;</span>Observer<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Attach<span style="color: #008000;">&#40;</span>Observer observer<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        observers<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>observer<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Detach<span style="color: #008000;">&#40;</span>Observer observer<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        observers<span style="color: #008000;">.</span><span style="color: #0000FF;">Remove</span><span style="color: #008000;">&#40;</span>observer<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Notify<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>var observer <span style="color: #0600FF; font-weight: bold;">in</span> observers<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            observer<span style="color: #008000;">.</span><span style="color: #0000FF;">Update</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">abstract <span style="color: #6666cc; font-weight: bold;">class</span> Observer
<span style="color: #008000;">&#123;</span>
    abstract <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Update<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #6666cc; font-weight: bold;">class</span> ConcreteSubject <span style="color: #008000;">:</span> Subject
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">int</span> value<span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> Value
    <span style="color: #008000;">&#123;</span>
        get
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> value<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        set
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">value</span> <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
            Notify<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #6666cc; font-weight: bold;">class</span> ConcreteObserver <span style="color: #008000;">:</span> Observer
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> ConcreteSubject subject<span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">void</span> Update<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Subject value is {0}.&quot;</span>, subject<span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> ConcreteObserver<span style="color: #008000;">&#40;</span>ConcreteSubject subject<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        subject<span style="color: #008000;">.</span><span style="color: #0000FF;">Attach</span><span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">subject</span> <span style="color: #008000;">=</span> subject<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    ~ConcreteObserver<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        subject<span style="color: #008000;">.</span><span style="color: #0000FF;">Detach</span><span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #6666cc; font-weight: bold;">class</span> Program
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> Main<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> args<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        var concreteSubject <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> ConcreteSubject<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        var concreteObserver <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> ConcreteObserver<span style="color: #008000;">&#40;</span>concreteSubject<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        concreteSubject<span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">10</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>As an output you will have: <strong>Subject value is 10</strong>.</p>
<h3>Links</h3>
<p><a href="http://en.wikipedia.org/wiki/Observer_pattern">Observer pattern description in Wikipedia</a></p>
]]></content:encoded>
			<wfw:commentRss>http://starikovs.com/2011/03/11/observer-pattern-example-csharp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Split string but keep separator in C#</title>
		<link>http://starikovs.com/2011/02/18/split-string-but-keep-separator-in-c/</link>
		<comments>http://starikovs.com/2011/02/18/split-string-but-keep-separator-in-c/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 15:37:57 +0000</pubDate>
		<dc:creator>Vacheslav</dc:creator>
				<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://starikovs.com/?p=425</guid>
		<description><![CDATA[Today I tried to split the string but preserve split characters. I didn&#8217;t find native methods for this need. If somebody know how to do it please write the comment. Here is my code: var separator = '@'; var result = new Dictionary&#60;int, string&#62;&#40;&#41;; var key = 0; for &#40;var i = 0; i &#60; [...]]]></description>
			<content:encoded><![CDATA[<p>Today I tried to split the string but preserve split characters. I didn&#8217;t find native methods for this need. If somebody know how to do it please write the comment.</p>
<p>Here is my code:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">var separator <span style="color: #008000;">=</span> <span style="color: #666666;">'@'</span><span style="color: #008000;">;</span>
var result <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Dictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">int</span>, <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
var key <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span>var i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&lt;</span> testString<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span><span style="color: #008000;">;</span> i<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    var c <span style="color: #008000;">=</span> testString<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>c <span style="color: #008000;">==</span> separator<span style="color: #008000;">&#41;</span> key<span style="color: #008000;">++;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>result<span style="color: #008000;">.</span><span style="color: #0000FF;">ContainsKey</span><span style="color: #008000;">&#40;</span>key<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        result<span style="color: #008000;">&#91;</span>key<span style="color: #008000;">&#93;</span> <span style="color: #008000;">+=</span> c<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #0600FF; font-weight: bold;">else</span>
    <span style="color: #008000;">&#123;</span>
        result<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>key, c<span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://starikovs.com/2011/02/18/split-string-but-keep-separator-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting String to Single in C#</title>
		<link>http://starikovs.com/2010/03/16/converting-string-to-single-in-c/</link>
		<comments>http://starikovs.com/2010/03/16/converting-string-to-single-in-c/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 17:09:45 +0000</pubDate>
		<dc:creator>Vacheslav</dc:creator>
				<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://starikovs.com/?p=214</guid>
		<description><![CDATA[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&#8217;s example project called FlashTools. I downloaded it and stated to use. While I was using this code I found a little bug [...]]]></description>
			<content:encoded><![CDATA[<p>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 <a href="http://blogs.msdn.com/mswanson/" target="_blank">Mike Swanson&#8217;s</a> 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 &#8220;Input string was not in a correct format&#8221;. A fix was very simple, I just passed the <code>InvariantCulture</code> as the second parameter of <code>Convert.ToSingle</code> method.<br />
<span id="more-214"></span><br />
A code snippet that causes an error:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">// private Single frameRate = 0.0F;</span>
<span style="color: #6666cc; font-weight: bold;">string</span> sFrameRate <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Format</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;{0}.{1}&quot;</span>, frameRateMajor, frameRateMinor<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">frameRate</span> <span style="color: #008000;">=</span> Convert<span style="color: #008000;">.</span><span style="color: #0000FF;">ToSingle</span><span style="color: #008000;">&#40;</span>sFrameRate<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>A workaround:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">// private Single frameRate = 0.0F;</span>
<span style="color: #6666cc; font-weight: bold;">string</span> sFrameRate <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Format</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;{0}.{1}&quot;</span>, frameRateMajor, frameRateMinor<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">frameRate</span> <span style="color: #008000;">=</span> Convert<span style="color: #008000;">.</span><span style="color: #0000FF;">ToSingle</span><span style="color: #008000;">&#40;</span>sFrameRate, 
  <span style="color: #000000;">System.<span style="color: #0000FF;">Globalization</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">CultureInfo</span><span style="color: #008000;">.</span><span style="color: #0000FF;">InvariantCulture</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>Using the <code>System.Globalization.CultureInfo.InvariantCulture</code> the <code>Convert.ToSingle</code> method converts String to Single using the specified culture-specific formatting information.</p>
<h3>Links</h3>
<p><a href="http://blogs.msdn.com/mswanson/archive/2006/10/15/example-c-code-for-reading-flash-swf-files.aspx" target="_blank">Example C# Code for Reading Flash (SWF) Files</a></p>
<p><a href="http://msdn.microsoft.com/en-us/library/w7zs80w4%28VS.85%29.aspx" target="_blank">Convert.ToSingle Method</a></p>
]]></content:encoded>
			<wfw:commentRss>http://starikovs.com/2010/03/16/converting-string-to-single-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting HTML for WebBrowser in C#</title>
		<link>http://starikovs.com/2009/11/25/set-html-webbrowser-csharp/</link>
		<comments>http://starikovs.com/2009/11/25/set-html-webbrowser-csharp/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 16:39:53 +0000</pubDate>
		<dc:creator>Vacheslav</dc:creator>
				<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://starikovs.com/?p=155</guid>
		<description><![CDATA[Today I tryed to insert HTML for WebBorwser in C#. I thought it&#8217;s a simple task. But when I tryed to use DocumentText property I got &#8220;&#60;HTML&#62;&#60;/HTML&#62;&#8221;. 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 [...]]]></description>
			<content:encoded><![CDATA[<p>Today I tryed to insert HTML for <code>WebBorwser</code> in C#. I thought it&#8217;s a simple task. But when I tryed to use <code>DocumentText</code> property I got &#8220;&lt;HTML&gt;&lt;/HTML&gt;&#8221;. Then I tryed <code>Document.Write("...")</code> and I got that <code>Document</code> is <code>null</code>. 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:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">WebBrowser browser <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> WebBrowser<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
browser<span style="color: #008000;">.</span><span style="color: #0000FF;">Navigate</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;about:blank&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
browser<span style="color: #008000;">.</span><span style="color: #0000FF;">Document</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&lt;html&gt;&lt;body&gt;...&lt;/body&gt;&lt;/html&gt;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>When the <code>WebBrowser</code> has been made, the <code>Document</code> object is <code>null</code>. So, we should call <code>Navigate()</code> method to get <code>Document</code> available.</p>
<p>If You have Your way to fill the <code>WebBrowser</code> with HTML I&#8217;m expecting for Your comments <img src='http://starikovs.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://starikovs.com/2009/11/25/set-html-webbrowser-csharp/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

