2008年5月15日

摘要: Recently I got a classic WD 740GD hard disk (Raptor II), and I decided move the whole Vista system to this monster without reinstall. I thought this is simple, but at last, it costed me 3 nights. Th... 阅读全文
posted @ 2008-05-15 00:03 谢绝围观 阅读(388) 评论(0) 推荐(0) 编辑

2008年5月7日

摘要: 手上有一个DataGridView,绑定了一个BindingList。BindingList声明如下:privateBindingList<Report>reportsInGrid; Report有一个property名为DisplayOrder,现在需要在DisplayOrder改变时立即对List重新排序。拟在CellEndEdit事件中处理排序。 注意到BindingList本身... 阅读全文
posted @ 2008-05-07 18:33 谢绝围观 阅读(2527) 评论(3) 推荐(0) 编辑

2008年4月15日

摘要: 昨天碰到一个很费解的问题。我们在程序里使用了ReportViewer控件,当调用了控件RefreshReport方法后,整个Application的UI响应都变得很慢。尝试将引用升级到ReportViewer 9.0,也不能解决问题。 排除了其他可能后,MSDN搜索ReportView + RefreshReport关键字,得知reportviewer存在一个bug,该... 阅读全文
posted @ 2008-04-15 10:43 谢绝围观 阅读(1517) 评论(2) 推荐(0) 编辑

2008年4月4日

摘要: 这篇曾经贴在自己的live space上,今天整理出来发在这里。 内容参考了《重构》和《设计模式》 Case如下,假设Employee类中有这样两个方法: PayAmount. 根据员工类型获得员工的薪水: public int PayAmount(EmployeeType empType) { switch (empT... 阅读全文
posted @ 2008-04-04 22:04 谢绝围观 阅读(3470) 评论(13) 推荐(0) 编辑

2008年3月30日

摘要: System.Collections命名空间下的BitArray相当于一个bool类型的数组bool[]。MSDN用BitArray做例子实现了一个索引器,今天研究了一下这个例子,对原来的实现做了一些改变,将>> 5操作变成了divide 32,敝人以为这样看起来会更直观。代码如下:publicclassMyBitArray{privateint[]m_Bits;privateintm_Length;staticprivateconstintMASK0x1F;publicMyBitArray(intlength){//Comment1m_Length=(length-1)/32+1 阅读全文
posted @ 2008-03-30 11:46 谢绝围观 阅读(763) 评论(0) 推荐(0) 编辑

2008年3月23日

摘要: as关键字最大的好处就是,当转换不能进行的时候,会返回一个空值,而不是抛异常。 其实现类似于这样的语句:expression is type ? (type)expression : (type)null。 一个应用场景是,DataGridView中cell的value是一个object类型。如果想判断用户的输入是不是空串,需要这样判断: If((cell.Value != null) &&(... 阅读全文
posted @ 2008-03-23 16:57 谢绝围观 阅读(162) 评论(0) 推荐(0) 编辑

2008年3月21日

摘要: 解决了上午提到的 Build Error: The command ****** exited with code 9009 以后,又碰到一个新问题。在post build里尝试注册assembly失败,提示如题。 google之,发现主要是VISTA用户反映存在这个问题,跟我的情况没什么关系。 最终发现原因是VS 不能使用.NET Framework安装目录下的gacutil工具! (之前把... 阅读全文
posted @ 2008-03-21 20:20 谢绝围观 阅读(1021) 评论(0) 推荐(0) 编辑
摘要: build某个project的时候提示了这个错误,google到这篇文章:http://support.microsoft.com/kb/908268。 提示将regasm的完整路径写在命令里,如:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\regasm.exe。 看来是VS2005不能取到.NET Framework的安装路径。 于是将pose... 阅读全文
posted @ 2008-03-21 10:53 谢绝围观 阅读(2202) 评论(0) 推荐(0) 编辑

2008年3月14日

摘要: 1. Don't add/delete elements in a foreach cycle. 不要在foreach遍历循环里做添加删除元素的操作。 2. When remove multi elements, remove from the last element, not the first. 删除多个元素的时候,从最后一个元素开... 阅读全文
posted @ 2008-03-14 13:47 谢绝围观 阅读(140) 评论(0) 推荐(0) 编辑

2008年2月13日

摘要: 使用.NET也有些日子了, 但对event这个东西一直没有去深入认识. 这两天因为想在DataGridView的cell里实现一个AutoComplete的功能, 趁机了解了一下, 下面贴上一点心得.Event机制其实是一个典型的Observer pattern: Publisher抛出一个事件, 所有订阅了该事件的Subscriber对此做出各自的响应.简单看下这个过程:Publisher:publicclassPublisher{//Publisherexposesaneventforsubscribers.publiceventEventHandlerOnPublish;publicvo 阅读全文
posted @ 2008-02-13 04:30 谢绝围观 阅读(618) 评论(4) 推荐(0) 编辑

导航