随笔分类 - C#
摘要:[一篮饭特稀原创,转载请注明出自http://www.cnblogs.com/wanghafan/p/5033186.html]基于面向XX编程的个人理解面向过程编程 Procedure Oriented Programming(POP)实现目的:分析出解决问题所需要的步骤,然后用函数把这些步骤一步...
阅读全文
摘要:[一篮饭特稀原创,转载请注明出自http://www.cnblogs.com/wanghafan/p/4754769.html]JsonWriter使用:前台 1 $.post("Ajax_EstimatedIncome.aspx/GetEstimatedIncomePlus", { Project...
阅读全文
摘要:[一篮饭特稀原创,转载请注明出自http://www.cnblogs.com/wanghafan/p/3412796.html]在NET 2.0以上版本提供了一种新的方法 就是加问号,DateTime? :表示可空类型,就是一种特殊的值类型,它的值可以为nullModel:1 private DateTime? _registrationtime;2 public DateTime? RegistrationTime3 {4 set{ _registrationtime=value;}5 get{return _registrationtime;}6 }Global.cs: 1...
阅读全文
摘要:[一篮饭特稀原创,转载请注明出自http://www.cnblogs.com/wanghafan/p/3371620.html]Ctrl+Shift+H查找内容\r\n\r\n //如果要替换换行前有空格的空行则 [^\S\r\n]\r\n替换内容\r\n查找范围-当前项目查找选项-使用正则表达式查找文件类型-*.cs多次点击全部替换
阅读全文
摘要:[一篮饭特稀原创,转载请注明出自http://www.cnblogs.com/wanghafan/p/3237772.html]在导入Excel读取数据时,其中的一个字段保存的值有如下格式:"2011072014","20110Aad10","25124Adfa","例子asdfadf" 这样的混合了 "字母/数字/中文"数据,在Excel表格中的前 8条 数据中的 这个列中的数据都是 由纯数字组成的,如"2011072012","2011072013",
阅读全文
摘要:[一篮饭特稀原创,转载请注明出自http://www.cnblogs.com/wanghafan/p/3228240.html] 1 using System; 2 using System.Data; 3 using System.IO; 4 using System.Windows.Forms; 5 using Excel = Microsoft.Office.Interop.Excel; 6 using System.Collections.Generic; 7 8 namespace PlaneExcel 9 { 10 static class Expor...
阅读全文
摘要:[一篮饭特稀原创,转载请注明出自http://www.cnblogs.com/wanghafan/p/3227351.html] 1 private void ChangBackColor() 2 { 3 if (dataGridView1.Rows.Count > 0) 4 { 5 foreach (DataGridViewRow row in dataGridView1.Rows) 6 { 7 if (row.Cells["列名"].Value.ToString() == "条件") 8 { 9...
阅读全文
摘要:[一篮饭特稀原创,转载请注明出处http://www.cnblogs.com/wanghafan/archive/2012/05/18/2508113.html]四舍五入View Code 1 public static decimal Round(decimal d, decimal unit)2 {3 decimal rm = d % unit;4 decimal result = d - rm;5 if (rm >= unit / 2)6 result ...
阅读全文
摘要:不规则 窗体 实现View Code 1 设置窗体属性TransparencyKey的颜色和需要屏蔽的颜色一致即可App.config读写View Code 1 读: 2 System.Configuration.ConfigurationSettings.AppSettings["KeyName"] 3 4 写: 5 XmlDocument doc = new XmlDocument(); 6 doc.Load(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile); 7 XmlNodeList nodes
阅读全文
摘要:1.当使用线程的时候,一般设置线程IsBackground=true;表示后台线程,主进程在被结束的时候也会自动结束所有后台线程。当false;表示前台进程,在没有结束该线程之前是不能结束主进程的。2.当一个线程为后台线程的时候,它是不能直接操作前台控件的,因为前台WinForm控件都是COM控件,只能被主进程调用。这时候就要用Invoke的委托来调用。View Code 1 public Form1() 2 { 3 InitializeComponent(); 4 Close(); 5 bTime = e.BeginTime; 6 eTime = ...
阅读全文
摘要:建立View Code 1 public enum 基本费率类型 2 3 { 4 5 光缆运杂费, 6 7 电缆运杂费, 8 9 塑料运杂费,10 11 木材运杂费,12 13 水泥运杂费,14 15 其他运杂费,16 17 };遍历View Code 1 foreach (string s in Enum.GetNames(typeof(Global.特殊费率类型))){}
阅读全文
摘要:利用PictureBox和Panel实现使用滚动条浏览大图片View Code 1 由于Picturebox控件在显示图片时不能直接使用滚动条,所以必须借助Panel控件实现以滚动条的方式浏览大图片。具体操作步骤如下: 2 3 (1)新建一个Windows应用程序,命名为“scrollBar”,调整窗体到适当大小。更改“Form1.cs”为“FormScrollBar.cs”。 4 5 (2)切换到代码方式,添加名称空间引用: 6 7 using System.Drawing.Drawing2D; 8 9 (3) 在窗体上分别添加一个button控件命名为“butto...
阅读全文
摘要:判断文件属性 只读 设置 为 可写View Code 1 File.SetAttributes(文件路径, FileAttributes.Normal);当前操作目录View Code 1 System.IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory +"InputModelDemo.xls")
阅读全文
摘要:Excel导入 数据库View Code 1 private void GetExcelData07(string str) 2 { 3 try 4 { 5 strCon = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" + str + "';Extended Properties='Excel 8.0;HDR=Yes;IMEX=1'"; 6 OleDbConnection myConn = new OleDbC...
阅读全文
摘要:[一篮饭特稀原创,转载请注明出处http://www.cnblogs.com/wanghafan/archive/2012/05/07/2487635.html]删除行View Code 1 protected void deleteDataRow(int RowID,DataTable dt)2 {3 for (int i = dt.Rows.Count - 1; i >= 0; i--)4 {5 if (Convert.ToInt32(dt.Rows[i]["RowID"]) == RowID)6 ...
阅读全文
摘要:遍历 HashTable DictionaryView Code 1 Dictionary<int, string> food = new Dictionary<int, string>(); // HashTable<int, string> food = new HashTable<int, string>(); 2 food.Add(1, "A"); 3 food.Add(2, "B"); 4 IDictionaryEnumerator myEnumerator=food.GetEnumerator(
阅读全文
摘要:请先设置窗体的keyPreView属性为True,确认控件的键盘事件向窗体注册;在窗体的KeyPress事件中编写如下代码:1 private void Form1_KeyPress(object sender, KeyPressEventArgs e) 2 { 3 if (e.KeyChar == (char)13)4 { 5 ... 6 } 7 }
阅读全文
摘要:--手动分页View Code 1 WordApp.Selection.InsertBreak(Missing.Value);--
阅读全文
摘要:[一篮饭特稀原创,转载请注明出处http://www.cnblogs.com/wanghafan/archive/2012/02/09/2344276.html]--简单例子:View Code 1 using System.Text;2 using System.Text.RegularExpressions;3 4 string str = "<img>123456789</img>";5 string regexStr = @"<img>([^<]*)&
阅读全文
摘要:NoiseScene.xml:View Code 1 <pre name="code" class="html"><?xml version="1.0" encoding="utf-8"?> 2 <DataTable> 3 <Rows> 4 <Scene>默认</Scene> 5 <Noise>-100</Noise> 6 </Rows> 7 <Rows> 8 <Scene>高层<
阅读全文

浙公网安备 33010602011771号