<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Xiaonan's Techlog</title>
	<atom:link href="http://xiaonanji.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://xiaonanji.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Sun, 08 Jan 2012 23:01:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='xiaonanji.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Xiaonan's Techlog</title>
		<link>http://xiaonanji.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://xiaonanji.wordpress.com/osd.xml" title="Xiaonan&#039;s Techlog" />
	<atom:link rel='hub' href='http://xiaonanji.wordpress.com/?pushpress=hub'/>
		<item>
		<title>The big interest conflict between a business manager and a modelling developer</title>
		<link>http://xiaonanji.wordpress.com/2012/01/08/the-big-interest-conflict-between-a-business-manager-and-a-modelling-developer/</link>
		<comments>http://xiaonanji.wordpress.com/2012/01/08/the-big-interest-conflict-between-a-business-manager-and-a-modelling-developer/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 23:01:22 +0000</pubDate>
		<dc:creator>Xiaonan Ji</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://xiaonanji.wordpress.com/?p=114</guid>
		<description><![CDATA[Working as a model developer, I have realized that the biggest interest conflict between a model developer and a business manager is how complicate the model ends up being. A model developer, on one hand, would like to develop a powerful model, which can perform its task, prediction, in accurate way. A business manager, on the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xiaonanji.wordpress.com&amp;blog=7530343&amp;post=114&amp;subd=xiaonanji&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Working as a model developer, I have realized that the biggest interest conflict between a model developer and a business manager is how complicate the model ends up being. A model developer, on one hand, would like to develop a powerful model, which can perform its task, prediction, in accurate way. A business manager, on the other hand, would try to avoid over-complicate model being used in his business.</p>
<p>This is common to explain. It is the business manager who ends up using the model and he has to interpret the outcome from the model. And since a business manager tend to be not very technical, he doesn&#8217;t want to get into the trouble of interpret something that he doesn&#8217;t fully understand. But this is not a problem from a model developer&#8217;s point of view. A developer is technically savvy enough to have the ball to use the complicate information and gets the max satisfaction of developing something powerful.</p>
<p>I believe the conflict is universal because the two sides have quite different standing ground. But a company appealing good developers is the company that has good managers who know technical stuff and have a tolerant bar higher than average ordinal companies. I believe in companies like Apple, Google and Microsoft, there are many managers who embrace fancy, complicate ideas and encourage developers to go to certain point of complication. On contrast, in some old companies with not much innovative atmosphere, managers can be very conservative.</p>
<p>If you are a good developer, always chasing fancy ideas, would like to indulge into complicate stuff and you find business managers are not very supportive, consider changing a place.</p>
<p>Until next time, happy modelling.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xiaonanji.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xiaonanji.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xiaonanji.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xiaonanji.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xiaonanji.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xiaonanji.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xiaonanji.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xiaonanji.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xiaonanji.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xiaonanji.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xiaonanji.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xiaonanji.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xiaonanji.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xiaonanji.wordpress.com/114/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xiaonanji.wordpress.com&amp;blog=7530343&amp;post=114&amp;subd=xiaonanji&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xiaonanji.wordpress.com/2012/01/08/the-big-interest-conflict-between-a-business-manager-and-a-modelling-developer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b2bb1c3de83615ed5a005885b213b76?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xiaonanji</media:title>
		</media:content>
	</item>
		<item>
		<title>How to embed icons/images in your .net project and use them in your code</title>
		<link>http://xiaonanji.wordpress.com/2010/11/19/how-to-embed-iconsimages-in-your-net-project-and-use-them-in-your-code/</link>
		<comments>http://xiaonanji.wordpress.com/2010/11/19/how-to-embed-iconsimages-in-your-net-project-and-use-them-in-your-code/#comments</comments>
		<pubDate>Fri, 19 Nov 2010 00:38:17 +0000</pubDate>
		<dc:creator>Xiaonan Ji</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://xiaonanji.wordpress.com/?p=110</guid>
		<description><![CDATA[First, put your icons in a folder under your project folder. Go to Properties/Resources, add existing icons. Go to your code and use Properties.Resoureces.ICONNAME to use the resource. Once you put icons in Resources, VS should recognize them and assist you with Intelisense.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xiaonanji.wordpress.com&amp;blog=7530343&amp;post=110&amp;subd=xiaonanji&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>First, put your icons in a folder under your project folder. Go to Properties/Resources, add existing icons. Go to your code and use Properties.Resoureces.ICONNAME to use the resource. Once you put icons in Resources, VS should recognize them and assist you with Intelisense.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xiaonanji.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xiaonanji.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xiaonanji.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xiaonanji.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xiaonanji.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xiaonanji.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xiaonanji.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xiaonanji.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xiaonanji.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xiaonanji.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xiaonanji.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xiaonanji.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xiaonanji.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xiaonanji.wordpress.com/110/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xiaonanji.wordpress.com&amp;blog=7530343&amp;post=110&amp;subd=xiaonanji&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xiaonanji.wordpress.com/2010/11/19/how-to-embed-iconsimages-in-your-net-project-and-use-them-in-your-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b2bb1c3de83615ed5a005885b213b76?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xiaonanji</media:title>
		</media:content>
	</item>
		<item>
		<title>INotifyPropertyChanged doesn&#8217;t work in asychronized style.</title>
		<link>http://xiaonanji.wordpress.com/2010/04/29/inotifypropertychanged-doesnt-work-in-asychronized-style/</link>
		<comments>http://xiaonanji.wordpress.com/2010/04/29/inotifypropertychanged-doesnt-work-in-asychronized-style/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 00:38:02 +0000</pubDate>
		<dc:creator>Xiaonan Ji</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Data binding]]></category>
		<category><![CDATA[Threading]]></category>

		<guid isPermaLink="false">http://xiaonanji.wordpress.com/?p=107</guid>
		<description><![CDATA[You can find some essays from net about this problem. I explain it in my own view and words. Normally, INotifyPropertyChanged interface is used when you want to update the UI as soon as the underlying data has been changed (in this context, mostly in a programmatic way). You will have your data object inherits [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xiaonanji.wordpress.com&amp;blog=7530343&amp;post=107&amp;subd=xiaonanji&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>You can find some essays from net about this problem. I explain it in my own view and words.</p>
<p>Normally, INotifyPropertyChanged interface is used when you want to update the UI as soon as the underlying data has been changed (in this context, mostly in a programmatic way). You will have your data object inherits from this interface, add an event and a method called PropertyChanged(). In your method, you will call any handler to the event if there is any. You will call your PropertyChanged() method at the end of every property setter attribute accessor or something that changes your data. Say more about it, the UI will subscribe the event when you bind the data to the UI. All simple and is good to use.</p>
<p>INotifyPropertyChanged doesn&#8217;t work in aschronized style. That is, if your PropertyChanged() method is called in a thread other than the thread creating the UI, you will get random errors. The ultermate evil is that UI updates should be performed in the same thread as it is created. When your PropertyChanged() method is called in a sub-thread, that sub-thread will call the event of INotifyPropertyChanged interface. As I said, that event will be subscribed by some UI control to update itself. So actually you try to update a UI in a different thread and that gives you the headaches.</p>
<p>A common scenario for this problem is the log system. You have a log system, which provides some kind of UI to show the tasks. When a task starts to execute, you want to update the UI about the change of the task status. When the task is running, you want to update the progress of the task. When the task is done, you want to show the end timestamp of the task. All these jobs involve updating the UI. If you bind the tasks to the UI using databinding, you will tend to use INotifyPropertyChanged to update the UI when the task data is changed. Since all tasks will be run in a BackgroundWorker, it is very likely that the BackgroundWorker will change the data of the tasks. So eventually, you will end up using the BackgroundWorker&#8217;s thread to call the PropertyChange() method in your task object, and the event of INotifyPropertyChanged interface as well. This is a common scenario to have the problem happening. It is my own experience by the way.</p>
<p>To fix this problem, you will need to make sure that your PropertyChanged() method uses InvokeRequired() and BeginInvoke() methods to make sure the calling of the event subscribers happens in the same thread as the UI. There are many ways to do this. For example, you can pass the reference of the UI control to your task object so when it is the time, it can check thread and execute the UI update in the correct one. Because most of the time, it is the main thread that owns all UI controls, we can even create a non-visible static singleton control object in a static method which will be sure to get called in the main thread. And everytime we create a new task item, we pass that non-visible control to the task item. As long as all the controls are in the same thread, using which one to call InvokeRequired() and BeginInvoke() doesn&#8217;t really matter.</p>
<p>Until next time, happy coding!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xiaonanji.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xiaonanji.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xiaonanji.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xiaonanji.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xiaonanji.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xiaonanji.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xiaonanji.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xiaonanji.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xiaonanji.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xiaonanji.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xiaonanji.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xiaonanji.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xiaonanji.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xiaonanji.wordpress.com/107/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xiaonanji.wordpress.com&amp;blog=7530343&amp;post=107&amp;subd=xiaonanji&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xiaonanji.wordpress.com/2010/04/29/inotifypropertychanged-doesnt-work-in-asychronized-style/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b2bb1c3de83615ed5a005885b213b76?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xiaonanji</media:title>
		</media:content>
	</item>
		<item>
		<title>RadioCheck is missing from MenuStrip control</title>
		<link>http://xiaonanji.wordpress.com/2010/04/29/radiocheck-is-missing-from-menustrip-control/</link>
		<comments>http://xiaonanji.wordpress.com/2010/04/29/radiocheck-is-missing-from-menustrip-control/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 00:19:03 +0000</pubDate>
		<dc:creator>Xiaonan Ji</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[.Net Control]]></category>

		<guid isPermaLink="false">http://xiaonanji.wordpress.com/?p=105</guid>
		<description><![CDATA[I am using .NET framework 3.5 and Visual Studio 2008 and I confirm that there is no RadioCheck property available for ToolStripMenuItem controls, usually used in MenuStrip control or ToolStrip control. This is inconvinent when you want several of your grouped ToolStripMenuItem controls behave like a set of radio buttons. Now you can only easily [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xiaonanji.wordpress.com&amp;blog=7530343&amp;post=105&amp;subd=xiaonanji&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I am using .NET framework 3.5 and Visual Studio 2008 and I confirm that there is no RadioCheck property available for ToolStripMenuItem controls, usually used in MenuStrip control or ToolStrip control. This is inconvinent when you want several of your grouped ToolStripMenuItem controls behave like a set of radio buttons. Now you can only easily set them as multiple check items.</p>
<p>To get the advantage from RadioCheck setting in menus, go back to MainMenu control. This control is similar to MenuStrip but its MainMenuItem controls have RadioCheck property. Notice that MainMenu control is not shown in the default tool list. You may need to manually add it to the tool list.</p>
<p>Until next time, happy coding.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xiaonanji.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xiaonanji.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xiaonanji.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xiaonanji.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xiaonanji.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xiaonanji.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xiaonanji.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xiaonanji.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xiaonanji.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xiaonanji.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xiaonanji.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xiaonanji.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xiaonanji.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xiaonanji.wordpress.com/105/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xiaonanji.wordpress.com&amp;blog=7530343&amp;post=105&amp;subd=xiaonanji&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xiaonanji.wordpress.com/2010/04/29/radiocheck-is-missing-from-menustrip-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b2bb1c3de83615ed5a005885b213b76?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xiaonanji</media:title>
		</media:content>
	</item>
		<item>
		<title>The difference between SelectedText and SelectedItem in ComboBox control</title>
		<link>http://xiaonanji.wordpress.com/2010/04/16/the-difference-between-selectedtext-and-selecteditem-in-combobox-control/</link>
		<comments>http://xiaonanji.wordpress.com/2010/04/16/the-difference-between-selectedtext-and-selecteditem-in-combobox-control/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 00:08:55 +0000</pubDate>
		<dc:creator>Xiaonan Ji</dc:creator>
				<category><![CDATA[.Net Control]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://xiaonanji.wordpress.com/?p=102</guid>
		<description><![CDATA[In ComboBox there are two properties, SelectedText and SelectedItem. SelectedItem property returns the currently selected object of the ComboBox. It can be any object. Use the ToString() method to get the string of the selected item if necessary. The SelectedText returns the editable text from the ComboBox. This property is only relavent when you set [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xiaonanji.wordpress.com&amp;blog=7530343&amp;post=102&amp;subd=xiaonanji&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In ComboBox there are two properties, SelectedText and SelectedItem. SelectedItem property returns the currently selected object of the ComboBox. It can be any object. Use the ToString() method to get the string of the selected item if necessary. The SelectedText returns the editable text from the ComboBox. This property is only relavent when you set the ComboBox&#8217;s DropDownStyle to either Simple or DropDown. In these two cases, you will find that you can enter arbitrary text to the ComboBox. Then you can use SelectedText to return at any time the text in the ComboBox. If you set the ComboBox&#8217;s DropDownStyle to DropDownList, you will notice that you cannot enter text of your own. Instead, you can only select existing items from the list. In this case, at any time, SelectedText returns an empty string.</p>
<p>SelectedText will be useful when you want to implement your own style of suggestion list of the ComboBox. You will need to combine the usage of this property with the KeyPress event of the ComboBox.</p>
<p>Until next time, happy coding!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xiaonanji.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xiaonanji.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xiaonanji.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xiaonanji.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xiaonanji.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xiaonanji.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xiaonanji.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xiaonanji.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xiaonanji.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xiaonanji.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xiaonanji.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xiaonanji.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xiaonanji.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xiaonanji.wordpress.com/102/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xiaonanji.wordpress.com&amp;blog=7530343&amp;post=102&amp;subd=xiaonanji&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xiaonanji.wordpress.com/2010/04/16/the-difference-between-selectedtext-and-selecteditem-in-combobox-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b2bb1c3de83615ed5a005885b213b76?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xiaonanji</media:title>
		</media:content>
	</item>
		<item>
		<title>BeginInvoke is asynchronized!</title>
		<link>http://xiaonanji.wordpress.com/2010/04/07/begininvoke-is-asynchronized/</link>
		<comments>http://xiaonanji.wordpress.com/2010/04/07/begininvoke-is-asynchronized/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 06:20:22 +0000</pubDate>
		<dc:creator>Xiaonan Ji</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://xiaonanji.wordpress.com/?p=96</guid>
		<description><![CDATA[BeginInvoke is a method you will call when you want to update a UI control within a thread other than the one the control is created. It is enforced by .net. For example, you have a TextBox control tb and you want to put a new text in it, normally, you will make a function: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xiaonanji.wordpress.com&amp;blog=7530343&amp;post=96&amp;subd=xiaonanji&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>BeginInvoke is a method you will call when you want to update a UI control within a thread other than the one the control is created. It is enforced by .net. For example, you have a TextBox control tb and you want to put a new text in it, normally, you will make a function:</p>
<p><code>void DisplayNewText(string text) { tb.Text = text; }</code></p>
<p>You may want to update your TextBox in a thread rather than the main thread. Usually, your TextBox control is created in the main thread, if so, you cannot call the above method in your sub-thread. In order to do so, you need to rewrite your above method to:<br />
<code><br />
void DisplayNewText(string text) {<br />
if(tb.InvokeRequired) BeginInvoke(new TextBoxDelegate(DisplayNewText), new object[] { text });<br />
else tb.Text = text;<br />
}<br />
</code></p>
<p>You need a delegate here:</p>
<p><code>delegate void TextBoxDelegate(string text);</code></p>
<p>The new DisplayNewText method first tests whether the call is made from the thread that the TextBox belongs to, if so, directly execute the else part. If not, it wraps itself into a delegate and pass the call of the delegate to the main thread, where the else part is executed then.</p>
<p>There is a point that I would like to make: the BeginInvoke method is execuated asynchronized. This actually means that it is not guranteed that the else part is executed immediately after the BeginInvoke call. This, actually may cause problem.</p>
<p>In a real product code, we put logs into a TextBox. New logs are put to TextBox in a sub-thread. To put the logs in better format, we use indentions to separate log sections. An example log section is as below:</p>
<p>[Optimization Begins]</p>
<p style="padding-left:30px;">Initial value: 0.345</p>
<p style="padding-left:30px;">Satisfied constraints: 3 of 3</p>
<p style="padding-left:30px;">Objective: 0.5</p>
<p>[Optimization Ends]</p>
<p>Our log system is consisted by many sections and sections can contain sections. To implement the indention, we use a stack to hold sections. Whenever a new section starts, we push it to the stack and whenever a section finishes, we pop it from the stack. When a log is added to the log system, we investigate the total numbers of sections held in the stack, to decide how many &#8220;\t&#8221; to put in front of each line of log:</p>
<p><code><br />
for(int i = 1; i &lt; Logging.NumSections; i++) tb.AppendText("\t");<br />
tb.AppendText(logMessage);<br />
</code></p>
<p>Then we found that some lines have wrong indention:</p>
<p>[Optimization Begines]</p>
<p style="padding-left:30px;">Initial value: 0.345</p>
<p style="padding-left:30px;">Satisfied constraints: 3 of 3</p>
<p>Objective: 0.5</p>
<p>[Optimization Ends]</p>
<p>In this example, clearly, Objective line&#8217;s indention is wrong. After investigation, we found that it is the BeginInvoke that causes this problem. Since BeginInvoke is asynchronized, it happens that after the BeingInvoke is called to display the Objective line, the thread hangs there and the main thread executes the exit of the section. Then when the else part is called from the BeginInvoke, the Logging.NumSections is short by one.</p>
<p>Now the story is, we should pass in whatever values we need at the time when BeginInvoke is called, rather than depends on some outside holder (here is the Logging class) to retrieve the value (here is the NumSections). If we use Logging.NumSections to get the number of sections held in stack, it is the number of sections held in stack when the else part is executed, rather than when the BeginInvoke is called. Timing is essential what&#8217;s going wrong in our story.</p>
<p>Of course, there are cases when the else part is executed, you want to use the value held NOW, rather than the value held when the BeginInvoke is called, in this case, retrieve the value from the outside holder makes sense.</p>
<p>Until next time, happy coding!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xiaonanji.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xiaonanji.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xiaonanji.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xiaonanji.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xiaonanji.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xiaonanji.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xiaonanji.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xiaonanji.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xiaonanji.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xiaonanji.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xiaonanji.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xiaonanji.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xiaonanji.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xiaonanji.wordpress.com/96/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xiaonanji.wordpress.com&amp;blog=7530343&amp;post=96&amp;subd=xiaonanji&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xiaonanji.wordpress.com/2010/04/07/begininvoke-is-asynchronized/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b2bb1c3de83615ed5a005885b213b76?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xiaonanji</media:title>
		</media:content>
	</item>
		<item>
		<title>Escaping curly brackets</title>
		<link>http://xiaonanji.wordpress.com/2009/12/02/escaping-curly-brackets/</link>
		<comments>http://xiaonanji.wordpress.com/2009/12/02/escaping-curly-brackets/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 23:41:58 +0000</pubDate>
		<dc:creator>Xiaonan Ji</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://xiaonanji.wordpress.com/?p=93</guid>
		<description><![CDATA[In string format, put two curly brackets together to escape it. For example, string.format(&#8220;{{{0}}}&#8221;, 34) outputs {34}.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xiaonanji.wordpress.com&amp;blog=7530343&amp;post=93&amp;subd=xiaonanji&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In string format, put two curly brackets together to escape it. For example, string.format(&#8220;{{{0}}}&#8221;, 34) outputs {34}.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xiaonanji.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xiaonanji.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xiaonanji.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xiaonanji.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xiaonanji.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xiaonanji.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xiaonanji.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xiaonanji.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xiaonanji.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xiaonanji.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xiaonanji.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xiaonanji.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xiaonanji.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xiaonanji.wordpress.com/93/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xiaonanji.wordpress.com&amp;blog=7530343&amp;post=93&amp;subd=xiaonanji&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xiaonanji.wordpress.com/2009/12/02/escaping-curly-brackets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b2bb1c3de83615ed5a005885b213b76?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xiaonanji</media:title>
		</media:content>
	</item>
		<item>
		<title>Work More Effectively As A Developer</title>
		<link>http://xiaonanji.wordpress.com/2009/11/30/work-more-effectively-as-a-developer/</link>
		<comments>http://xiaonanji.wordpress.com/2009/11/30/work-more-effectively-as-a-developer/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 23:44:05 +0000</pubDate>
		<dc:creator>Xiaonan Ji</dc:creator>
				<category><![CDATA[Project Management]]></category>

		<guid isPermaLink="false">http://xiaonanji.wordpress.com/?p=91</guid>
		<description><![CDATA[From Peopleware: There are several ways to make project or task (time) estimation. The estimation can be made by managers, developers themselves, managers + developers or system analysts. If estimation is made by managers, developers work in lowest efficiency. Managers + developers make things better. Amazingly, if estimation is made by developers themselves, they tend [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xiaonanji.wordpress.com&amp;blog=7530343&amp;post=91&amp;subd=xiaonanji&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>From Peopleware:</p>
<p>There are several ways to make project or task (time) estimation. The estimation can be made by managers, developers themselves, managers + developers or system analysts. If estimation is made by managers, developers work in lowest efficiency. Managers + developers make things better. Amazingly, if estimation is made by developers themselves, they tend to work better. Note that Baidu (the biggest search engine company in China) uses this way to estimate project schedules. But this is not the best way. Developers work even better when estimation is made by system analysts. The book says that because system analysts are the best people that can make best estimation and developers work better under better estimation. I just partly understand this.</p>
<p>But wait a second, what if no schedule is to be made? Developers work best if no schedule is made or need! Just wake me up when you done. Why? I guess, it is a matter of human pride. Let me summarize this up. If you are told be a manager to finish something in 2 days, and you think the manager doesn&#8217;t know better than you about the work, you wouldn&#8217;t work very hard to meet her schedule. If you and the manager agree that the work should be done in 2 days, you are involved and it is now part of your responsibility to meet the schedule. But the manager still interferes.  Now the manager asks you and you tell her that you will finish it in 2 days. What now? You need to work very hard to meet your own schedule. Otherwise, everyone else will think you are not very capable of doing your work and you lose credibility. When the system analyst says that you can finish the work in 2 days, she probably knows it well and you feel happy to meet her correct schedule. In above situations, you always have a schedule to meet. You don&#8217;t have to finish the work in 1 day if the schedule says you can/should finish it in 2 days. What if there is no schedule at all? The earlier you can finish the work, the better you impress everyone else and the better you feel in the company, and the greater the achievement is, and the harder you will work.</p>
<p>Developers are simply persons working with computers and programs everyday. The only thing they want best is the achievement, the agreement from everyone else about his ability. They will fight very hard to gain the honor. All they want is: to prove they can work quickly; to prove their code works beautifully; to see their code is used by others; to know everyone knows the above truth. If you can let them get all these, they will work harder than you can image.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xiaonanji.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xiaonanji.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xiaonanji.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xiaonanji.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xiaonanji.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xiaonanji.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xiaonanji.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xiaonanji.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xiaonanji.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xiaonanji.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xiaonanji.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xiaonanji.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xiaonanji.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xiaonanji.wordpress.com/91/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xiaonanji.wordpress.com&amp;blog=7530343&amp;post=91&amp;subd=xiaonanji&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xiaonanji.wordpress.com/2009/11/30/work-more-effectively-as-a-developer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b2bb1c3de83615ed5a005885b213b76?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xiaonanji</media:title>
		</media:content>
	</item>
		<item>
		<title>Enum Type in C#</title>
		<link>http://xiaonanji.wordpress.com/2009/11/11/enum-type-in-c/</link>
		<comments>http://xiaonanji.wordpress.com/2009/11/11/enum-type-in-c/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 00:31:42 +0000</pubDate>
		<dc:creator>Xiaonan Ji</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://xiaonanji.wordpress.com/?p=88</guid>
		<description><![CDATA[Enum items by default start from 0. So if you have an enum WeekDays { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday}; Then by default, Monday has a value of 0 and Tuesday has a value of 1 and so on. An enum variable has a default value of (WeekDays)0 (not null as objects). You [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xiaonanji.wordpress.com&amp;blog=7530343&amp;post=88&amp;subd=xiaonanji&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Enum items by default start from 0. So if you have an enum WeekDays { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday}; Then by default, Monday has a value of 0 and Tuesday has a value of 1 and so on. An enum variable has a default value of (WeekDays)0 (not null as objects).</p>
<p>You can explicitly change the numeric value of enum items. If you set a number to an enum item, the following items&#8217; numeric values are increased by 1 sequentially. Make sure you set the numeric values in a valid way. For example, if you set enum WeekDays { Monday = 1, Tuesday = 0, Wednesday, Thursday, Friday, Saturday, Sunday}; Then WeekDays.Monday will be conflicted to WeekDays.Wednesday and you will have trouble separating the two conflicted values.</p>
<p>Until next time, happy coding.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xiaonanji.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xiaonanji.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xiaonanji.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xiaonanji.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xiaonanji.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xiaonanji.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xiaonanji.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xiaonanji.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xiaonanji.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xiaonanji.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xiaonanji.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xiaonanji.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xiaonanji.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xiaonanji.wordpress.com/88/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xiaonanji.wordpress.com&amp;blog=7530343&amp;post=88&amp;subd=xiaonanji&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xiaonanji.wordpress.com/2009/11/11/enum-type-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b2bb1c3de83615ed5a005885b213b76?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xiaonanji</media:title>
		</media:content>
	</item>
		<item>
		<title>Pay attention when changing menu options</title>
		<link>http://xiaonanji.wordpress.com/2009/11/10/pay-attention-when-changing-menu-options/</link>
		<comments>http://xiaonanji.wordpress.com/2009/11/10/pay-attention-when-changing-menu-options/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 23:18:16 +0000</pubDate>
		<dc:creator>Xiaonan Ji</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[UI]]></category>

		<guid isPermaLink="false">http://xiaonanji.wordpress.com/?p=82</guid>
		<description><![CDATA[Many Windows applications use menus to organize the actions or options provided by the software. In some cases, the menu items will be changed. For example, according to a license, some options are disabled and invisible to users. Hiding menu items is a simple task in .NET but you must pay special attention when toolstrip [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xiaonanji.wordpress.com&amp;blog=7530343&amp;post=82&amp;subd=xiaonanji&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Many Windows applications use menus to organize the actions or options provided by the software. In some cases, the menu items will be changed. For example, according to a license, some options are disabled and invisible to users. Hiding menu items is a simple task in .NET but you must pay special attention when toolstrip separators are also used to group options in menus.</p>
<p>When a drop down menu list contains menu items and separators, and all menu items in a group are hidden because of certain reason, you will see two separators next to each other vertically in the menu drop down list, with nothing in between them. This is a UI defect that is easy to be overlooked.</p>
<p>A solution is to provide a function for removing menu items, for example, the following function.</p>
<p><!-- code formatted by http://manoli.net/csharpformat/ --></p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> RemoveMenuItem_(ToolStripMenuItem item, ToolStripMenuItem parent)</pre>
<pre><span class="lnum">   2:  </span>{</pre>
<pre class="alt"><span class="lnum">   3:  </span>    <span class="kwrd">int</span> indexOfRemoving = parent.DropDownItems.IndexOf(item);</pre>
<pre><span class="lnum">   4:  </span></pre>
<pre class="alt"><span class="lnum">   5:  </span>    <span class="kwrd">if</span>(indexOfRemoving + 1 &lt; parent.DropDownItems.Count) {</pre>
<pre><span class="lnum">   6:  </span>        var separatorBelow = parent.DropDownItems[indexOfRemoving + 1] <span class="kwrd">as</span> ToolStripSeparator;</pre>
<pre class="alt"><span class="lnum">   7:  </span></pre>
<pre><span class="lnum">   8:  </span>        <span class="kwrd">if</span> (separatorBelow != <span class="kwrd">null</span>)</pre>
<pre class="alt"><span class="lnum">   9:  </span>        {</pre>
<pre><span class="lnum">  10:  </span>            <span class="kwrd">int</span> indexOfAboveRemoving = indexOfRemoving - 1;</pre>
<pre class="alt"><span class="lnum">  11:  </span>            <span class="kwrd">if</span> (indexOfAboveRemoving &lt; 0 || parent.DropDownItems[indexOfAboveRemoving] <span class="kwrd">is</span> ToolStripSeparator)</pre>
<pre><span class="lnum">  12:  </span>            {</pre>
<pre class="alt"><span class="lnum">  13:  </span>                separatorBelow.Visible = <span class="kwrd">false</span>;</pre>
<pre><span class="lnum">  14:  </span>                parent.DropDownItems.Remove(separatorBelow);</pre>
<pre class="alt"><span class="lnum">  15:  </span>            }</pre>
<pre><span class="lnum">  16:  </span>        }</pre>
<pre class="alt"><span class="lnum">  17:  </span>    }</pre>
<pre><span class="lnum">  18:  </span></pre>
<pre class="alt"><span class="lnum">  19:  </span>    item.Enabled = <span class="kwrd">false</span>;</pre>
<pre><span class="lnum">  20:  </span>    item.Visible = <span class="kwrd">false</span>;</pre>
<pre class="alt"><span class="lnum">  21:  </span></pre>
<pre><span class="lnum">  22:  </span>    parent.DropDownItems.Remove(item);</pre>
<pre class="alt"><span class="lnum">  23:  </span>}</pre>
</div>
<p>The above code takes care of hiding and removing menu items and separators if necessary.</p>
<p>Until next time, happy coding.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xiaonanji.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xiaonanji.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xiaonanji.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xiaonanji.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xiaonanji.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xiaonanji.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xiaonanji.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xiaonanji.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xiaonanji.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xiaonanji.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xiaonanji.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xiaonanji.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xiaonanji.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xiaonanji.wordpress.com/82/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xiaonanji.wordpress.com&amp;blog=7530343&amp;post=82&amp;subd=xiaonanji&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xiaonanji.wordpress.com/2009/11/10/pay-attention-when-changing-menu-options/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b2bb1c3de83615ed5a005885b213b76?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xiaonanji</media:title>
		</media:content>
	</item>
	</channel>
</rss>
