随笔分类 - C#
摘要:// 拖动一个label 设置背景色为透明,不添加文字 添加以下代码private bool m_isMouseDown = false;private System.Drawing.Point m_mousePos = new System.Drawing.Point();private void label4_MouseDown(object sender, MouseEventArgs e){ base.OnMouseDown(e); m_mousePos = System.Windows.Forms.Cursor.Position; m_isMouseDown = true;}priv
阅读全文
摘要:// --------------------------上传图片并保存至数据库--------------------------------------// 从本地文件中读取图片System.IO.FileStream fs = new System.IO.FileStream(picPath, System.IO.FileMode.Open, System.IO.FileAccess.Read);// 创建buff存储二进制数据byte[] buffbyt = new byte[fs.Length];fs.Read(buffbyt, 0, (int)fs.Length);// 关闭文件流
阅读全文
摘要:WebService 是一种概念吗?你又是如何理解的呢?之前,我写的程序为了让代码和Html分开是用的 Request 对象,然后Switch 一下..WebService SOAP 神马的概念一头雾水,看了WebService的例子之后发现也就是在这个基础上省了一个Swith 方法,因为它直接把方法生成了url的一部分。下面写一个最简单的WebService 并指出其中所注意的事项1.VS2010 不支持 WebService?新建的时候,把.NET FrameWork 4.0 改成3.5 或者一下 新建Web服务后再改成 4.0为了让他们支持JSON 要是改成了2.0 就要记得在建立工程后
阅读全文
摘要:1.横轴显示时间zedGraphControl2.GraphPane.XAxis.Type = AxisType.Date;zedGraphControl2.GraphPane.XAxis.Scale.Format = "hh:mm";PointPairList list1 = new PointPairList();list1.Add((double)new XDate(ls[i - 1].dtime), ls[i - 1].volume);LineItem myCure = zedGraphControl2.GraphPane.AddCurve("流量&quo
阅读全文
摘要:<select id="Analysis" resultClass="stationGroupInfo" parameterclass="hashtable"> select <dynamic> <!--> 注意这里的$ 如果字符串直接拼接要用$,#默认会在字符串变量前面加引号的 --> <isNotEmpty property="AnalysiStr"> $AnalysiStr$ </isNotEmpty> </dynamic> <
阅读全文
摘要:/*使用OleDb连接*/using System.Data.OleDb;public int TransferData(string excelFile, string sheetName, string connectionString,int WeekId){ DataSet ds = new DataSet(); string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" + excelFile + "';Extended Properties='Excel 8
阅读全文
摘要:System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();stopwatch.Start(); // 开始监视代码运行时间/*代码放在这里*/stopwatch.Stop(); // 停止监视TimeSpan timespan = stopwatch.Elapsed; // 获取当前实例测量得出的总时间double seconds = timespan.TotalSeconds; // 总秒数MessageBox.Show(seconds.ToString()+"秒");
阅读全文
摘要:// 将ILayer转换为IFeaturelayer,为了对图层上的要素进行编辑ILayer pLayer = GetGallery(ActiveGallery);IFeatureLayer pFeatureLyr = pLayer as IFeatureLayer;// 定义一个要素集合,并获取图层的要素集合IFeatureClass pFeatCls = pFeatureLyr.FeatureClass;// 定义一个实现添加要素的接口实例,并该实例作用于当前图层的要素集IFeatureClassWrite fr = (IFeatureClassWrite)pFeatCls;// 定义一个
阅读全文
摘要:/*按某属性值查询,并将查询结果显示在一个新的图层中*/// 将图层声明为矢量图层IFeatureLayer pFeatureLayer = GetGallery(gallery) as IFeatureLayer;// 创建选择集IFeatureSelection pFeatSel;pFeatSel = pFeatureLayer as IFeatureSelection;// 设定选定的颜色Color color = this.SelectedLineColor;pFeatSel.SelectionColor = GetRGB(color.R, color.G, color.B);// 创
阅读全文
摘要:string strPath = "F:\\汇总--路段速度\\";// 路径DirectoryInfo mydir=new DirectoryInfo(strPath); // 得到文件列表FileInfo[] files=mydir.GetFiles();string filePath = mydir + files[i].Name;//以流的形式打开文本文件FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);// 创建readerstreamReader st
阅读全文
摘要:1.在web.config网页应用程序或者app.config (桌面应用程序)中添加,好像是必须在<configuration> </configuration>下添加 <appSettings> <add key="connstring" value="uid=sa;pwd=123456;database=bjtrc;server=(local)" /> </appSettings>2.添加引用 using System.Configuration;3.利用 string strConn =
阅读全文
摘要:/*可能回由于office版本问题造成异常*/protected void ExportExcel(System.Data.DataTable dt,string fileName){ if (dt == null || dt.Rows.Count == 0) return; Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application(); if (xlApp == null) { return; } System.Globalization.Cult...
阅读全文
摘要:DataGridViewTextBoxColumn col1 = new DataGridViewTextBoxColumn(); col1.HeaderText = "姓名"; col1.DataPropertyName = "Name"; col1.Name = "Name"; col1.Width = 100; DataGridViewTextBoxColumn col2 = new DataGridViewTextBoxColumn(); col2.HeaderText = "性别"; col2.DataP
阅读全文

浙公网安备 33010602011771号