Duonet_Blog

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

随笔分类 -  C#

摘要://CPU个数m_ProcessorCount=Environment.ProcessorCount;//获得物理内存ManagementClassmc=newManagementClass("Win32_ComputerSystem");ManagementObjectCollectionmoc=mc.GetInstances();foreach(ManagementObjectmoinmoc){if(mo["TotalPhysicalMemory"]!=null){m_PhysicalMemory=long.Parse(mo["TotalP 阅读全文
posted @ 2013-06-24 08:35 Duonet 阅读(442) 评论(0) 推荐(0)

摘要:View Codestring key = @"SYSTEM\CurrentControlSet\Services\" + ServiceName;注意这里的斜杠,网上大多数的例子都是/,使用这个斜杠找不到sub的值。1privatevoidSetServiceTable(stringServiceName)2{3RegistryKeyrk=Registry.LocalMachine;4stringkey=@"SYSTEM\CurrentControlSet\Services\"+ServiceName;5RegistryKeysub=rk.OpenSu 阅读全文
posted @ 2013-06-20 10:03 Duonet 阅读(343) 评论(0) 推荐(0)

摘要:#region将获得的安装软件信息格式转换成Json格式publicstaticstringJSON<InstallSoftDataEnitity>(List<InstallSoftDataEnitity>installSoftsData){System.Text.StringBuilderst=newSystem.Text.StringBuilder();try{System.Runtime.Serialization.Json.DataContractJsonSerializers=newSystem.Runtime.Serialization.Json.DataC 阅读全文
posted @ 2013-06-19 19:51 Duonet 阅读(595) 评论(0) 推荐(0)

摘要:本例子只是单纯的实现了工作中的功能,只能针对个别吧,如有错,莫见怪,谢谢。 #region 绑定TreeView控件 private void InitCountSignScopeJson() { NetWorkClient.StrCallBack callBack = delegate(String str) { if (str != null) { JArray orgAndPerson = (JArray)JsonCo... 阅读全文
posted @ 2013-06-09 09:56 Duonet 阅读(1170) 评论(0) 推荐(0)

摘要://将选中的数据添加到ListBox中 private void tvCountsignScope_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e) { // 选中最后一层的节点 if (!((TreeViewItem)(((TreeView)(sender)).SelectedItem)).HasItems) { // 将其值添加到集合中 // 要做一个判断,若是有相同的值,则不再添加 lbCountsignScope.Items.Add((e.NewValue as Tree 阅读全文
posted @ 2013-06-09 09:48 Duonet 阅读(248) 评论(0) 推荐(0)

摘要:C#字符串拼接的方法常用的有:StringBuilder、+、string.Format、List<string>。使用情况不同,效率不同。1.+的方式string sql = "update tableName set int1=" + int1.ToString() + ",int2=" + int2.ToString() + ",int3=" + int3.ToString() + " where id=" + id.ToString();编译器会优化为:string sql = string.C 阅读全文
posted @ 2013-06-09 09:16 Duonet 阅读(264) 评论(0) 推荐(0)

摘要:DataGridView控件(转)DataGridView是用于Windows Froms 2.0的新网格控件。它可以取代先前版本中DataGrid控件,它易于使用并高度可定制,支持很多我们的用户需要的特性。关于本文档:本文档不准备面面俱到地介绍DataGridView,而是着眼于深入地介绍一些技术点的高级特性。本文档按逻辑分为5个章节,首先是结构和特性的概览,其次是内置的列/单元格类型的介绍,再次是数据操作相关的内容,然后是主要特性的综述,最后是最佳实践。大部分章节含有一个“Q & A”部分,来回答该章节相关的一些常见问题。注意,某些问题会由于知识点的关联性重复出现在多个章节。这些问 阅读全文
posted @ 2013-05-09 18:48 Duonet 阅读(862) 评论(0) 推荐(1)

摘要:很多应用要用到TreeView来显示组织机构,以下演示TreeView如何与数据库进行绑定。数据库结构如下(递归现实):id(guid) pid(guid) name18a83618-8751-47ef-91a0-e2dcde42bb71**公司c775c004-48ed-4664-8b0c-8fd26fea5f4e 18a83618-8751-47ef-91a0-e2dcde42bb71 A部门a43696f0-a906-4b4a-8abf-a01fb7d54daf c775c004-48ed-4664-8b0c-8fd26fea5f4e A部门->1班组0d7fb83a-c056-4 阅读全文
posted @ 2013-05-05 00:14 Duonet 阅读(209) 评论(0) 推荐(0)

摘要:(转)1、DateTime 数字型 System.DateTime currentTime=new System.DateTime(); 1.1 取当前年月日时分秒 currentTime=System.DateTime.Now; 1.2 取当前年 int 年=currentTime.Year; 1.3 取当前月 int 月=currentTime.Month; 1.4 取当前日 int 日=currentTime.Day; 1.5 取当前时 int 时=currentTime.Hour; 1.6 取当前分 int 分=currentTime.Minute; 1.7 取当前秒 int 秒=cu 阅读全文
posted @ 2013-04-26 13:41 Duonet 阅读(181) 评论(0) 推荐(0)