随笔分类 -  C#开发

摘要:SaveFileDialog sfd = new SaveFileDialog(); sfd.DefaultExt = "xls"; sfd.Filter = "Excel文?件t(*.xls)|*.xls"; if (sfd.ShowDialog() == Dialo... 阅读全文
posted @ 2015-09-04 18:02 best.lei 阅读(688) 评论(0) 推荐(0) 编辑
摘要:C# 获取本机的串口号 using System.IO.Ports; //头文件 string[] PortNames = SerialPort.GetPortNames(); //获取本机串口名称,存入PortNames数组中 for (int i = 0; i < PortNa... 阅读全文
posted @ 2015-09-04 17:57 best.lei 阅读(194) 评论(0) 推荐(0) 编辑
摘要:C# 将二进制流转化成图片格式 MemoryStream ms = new MemoryStream(photo); Bitmap bmpt = new Bitmap(ms); //将二进制流转化成图片格式 SickPicture.Image = bmpt; //SickPi... 阅读全文
posted @ 2015-09-04 17:50 best.lei 阅读(512) 评论(0) 推荐(0) 编辑
摘要:DSO Framer Control Object 实现加载word文件的不可编辑 axFramerControl1.Open(OldPath); this.axFramerControl1.set_EnableFileCommand(DSOFramer.dsoFileCommandType... 阅读全文
posted @ 2015-08-27 00:30 best.lei 阅读(1299) 评论(0) 推荐(0) 编辑
摘要:将图片转换成二进制插入数据库 FileStream fs = new FileStream("D:\\Add.ico",FileMode.Open); byte[] imagebytes = new byte[fs.Length]; BinaryReader br = new BinaryRe... 阅读全文
posted @ 2015-08-27 00:25 best.lei 阅读(1237) 评论(0) 推荐(0) 编辑
摘要:private int ExistOrNot(string name) //判断当前数据表是否存在 { con = new SqlConnection(s); DataSet ds = new DataSet(); string strSQL = "select name from syso... 阅读全文
posted @ 2015-08-27 00:21 best.lei 阅读(1547) 评论(0) 推荐(0) 编辑
摘要:C#MessageBox用法: DialogResult dr = MessageBox.Show("是否删除?", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information); if (dr == DialogResul... 阅读全文
posted @ 2015-08-27 00:21 best.lei 阅读(190) 评论(0) 推荐(0) 编辑
摘要://CurrentCommunication为解决方案的名字,dynamic为图片的名字pictureBox1.Image = CurrentCommunication.Properties.Resources.dynamic; 阅读全文
posted @ 2015-08-27 00:17 best.lei 阅读(298) 评论(0) 推荐(0) 编辑
摘要:基本信息设置 progressBar1.Maximum = 1000; //设置ProgressBar的最大值 progressBar1.Value = 0; //ProgressBar的初始值 progressBar1.Step = 5; //ProgressBar的增长度 for (i... 阅读全文
posted @ 2015-08-27 00:16 best.lei 阅读(283) 评论(0) 推荐(0) 编辑
摘要:c#创建数据库表: private void CreatTable(string name) //创建数据库源数据表,name为表名 { con.ConnectionString = s; con.Open(); string sql = "CREATE TABLE " + name + "(Lin... 阅读全文
posted @ 2015-08-27 00:12 best.lei 阅读(1637) 评论(0) 推荐(0) 编辑
摘要:连接数据库操作: string s = "Data Source=服务器名称;Initial Catalog=数据库名称;Integrated Security=True"; //连接数据库所需要的字符串 SqlConnection con = new SqlConnection(); c... 阅读全文
posted @ 2015-08-27 00:10 best.lei 阅读(182) 评论(0) 推荐(0) 编辑
摘要:treeView1.SelectedNode = treeView1.Nodes[0]; //选中当前treeview控件的根节点为当前节点添加子节点: TreeNode tmp; tmp = new TreeNode("需要添加的内容"); treeView1.Se... 阅读全文
posted @ 2015-08-26 23:58 best.lei 阅读(291) 评论(0) 推荐(0) 编辑
摘要:string pathname = dt.ToString().Replace(":", ""); string str = richTextBoxResult.Text; str = str.Replace("\n", "\r\n"); //关键 File.AppendAllText(@"D... 阅读全文
posted @ 2015-08-26 23:50 best.lei 阅读(973) 评论(0) 推荐(0) 编辑
摘要:private static void InitRichTextBoxContextMenu(RichTextBox textBox) { //创建剪切子菜单 var cutMenuItem = new System.Windows.Forms.MenuItem("剪切"); cutMenuItem 阅读全文
posted @ 2015-08-26 23:48 best.lei 阅读(2004) 评论(0) 推荐(0) 编辑
摘要:FileStream fs = new FileStream(@"D:\text.txt", FileMode.Append); StreamWriter sw = new StreamWriter(fs, Encoding.Default); sw.Write(strAnalasy)... 阅读全文
posted @ 2015-08-26 23:44 best.lei 阅读(6160) 评论(0) 推荐(0) 编辑
摘要:备份数据库: string connectionString = "server=服务器名称;database=数据库名;uid=登入名;pwd=登入密码"; //登入名和密码在SQL Server中查找 private void btnBackDataBase_Click(... 阅读全文
posted @ 2015-08-26 06:39 best.lei 阅读(2931) 评论(0) 推荐(0) 编辑