代码改变世界

随笔分类 -  01 编程技巧

窗体传值,子窗体,父窗体,反射,reflection,windows,组策略,gpedit.msc,动态创建窗体,谢谢

2008-05-26 23:00 by Virus-BeautyCode, 3048 阅读, 收藏, 编辑
摘要: 大家好!刚才快下班的时候我正在写一个winform的程序,界面是treeview+listview的联动,就好像windows的组策略的样子,在子窗体中修改策略的安全设置,在主窗体中刷新显示,见下图:一想,不就是子父窗体传值吗,我以前做过啊,还写过两篇教程呢。c#,winform,show,showdialog,子窗体,父窗体,传值,输入正确 winform+c#之窗体之间的传值 就开始写了,就利... 阅读全文

c#.winform,datagridview,数组,绑定,字符串,字符串数组绑定datagridview显示,长度,显示数组内容

2008-05-25 15:47 by Virus-BeautyCode, 5057 阅读, 收藏, 编辑
摘要: 使用字符串数组绑定datagridveiw控件的时候,默认显示的是字符串的长度,是因为网格查找数组对象的第一个属性,并且显示这个属性,长度就是第一个属性,可是我们要显示的是字符串的内容。下面首先是默认显示图片和代码 using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;... 阅读全文

c#,winform,UserContrl,用户控件开发,窗体

2008-05-25 15:04 by Virus-BeautyCode, 11552 阅读, 收藏, 编辑
摘要: 用户控件效果如上图代码如下: using System;using System.Collections.Generic;using System.ComponentModel;using System.Drawing;using System.Data;using System.Text;using System.Windows.Forms;namespace WindowsControlLi... 阅读全文

c#,winform,show,showdialog,子窗体,父窗体,传值,输入正确

2008-05-25 14:27 by Virus-BeautyCode, 8753 阅读, 收藏, 编辑
摘要: 窗体的show方法,没有给调用代码任何通知,如果需要通知,使用showdialog是一种好的选择。在调用show方法后,show方法后面的代码会立即执行,调用showdialog方法后,调用代码被暂停执行,等到调用showdialog方法的窗体关系后再继续执行。而且窗体可以返回一个dialogresult值,他描述了窗体关闭的原因,例如OK,Cancel,yes,no等。为了让窗体返回一个dial... 阅读全文

c#,winform,progressbar+labe,联动显示进度

2008-05-15 11:12 by Virus-BeautyCode, 22601 阅读, 收藏, 编辑
摘要: Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> private void btnCount_Click(object sender, EventArgs e) { label1.Visible=true; progressBar.Visible = ... 阅读全文

c#+winform+combobox+动态生成控件,根据选择的内容

2008-05-15 09:43 by Virus-BeautyCode, 8914 阅读, 收藏, 编辑
摘要: 根据combobox选择的内容生成控件,窗体添加一个combobox和一个panel,在panel中添加控件,方便添加其他控件之前可以清除以前的控件Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->using System;using System.Co... 阅读全文

【转载】窗体之间的控件拖动

2008-05-06 12:49 by Virus-BeautyCode, 901 阅读, 收藏, 编辑
摘要: 原作者: LeoMaya用DoDragDrop可以做到的 首先, 封装一个DragDropObject的Class C# code public class MovingObject { protected Control control; public MovingObject(Control ctrl) { ... 阅读全文

通过ActiveX执行文件

2008-05-05 15:35 by Virus-BeautyCode, 549 阅读, 收藏, 编辑
摘要: !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"html xmlns="http://www.w3.org/1999/xhtml" head title无标题页/title script type="text/vbscript" function run_file() Set objShell=CreateObject("WScript.Shell") objShell.Run 阅读全文

通过双击listview中的项目来打开新窗体,有点像组策略中的双击一条策略,然后弹出相应的窗体,修改策略

2008-04-29 15:38 by Virus-BeautyCode, 1096 阅读, 收藏, 编辑
摘要: Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->private void listView1_DoubleClick(object sender, EventArgs e) { //Messag... 阅读全文

运行时通过拖拽动态改变控件的大小

2008-04-29 09:26 by Virus-BeautyCode, 1913 阅读, 收藏, 编辑
摘要: Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using Syst... 阅读全文

saucer(思归)解决的关于:页面A.aspx 动态载入用户自定义控件a.ascx,但a.ascx中的按钮提交后,不执行按钮的事件,而是直接刷新页面

2008-04-17 15:00 by Virus-BeautyCode, 1025 阅读, 收藏, 编辑
摘要: 还没解决啊?象我前面说的,你需要记住你目前的控件,然后在Page_Load或以前事件里重新Load,下面是个简单的例子,试着在文本框里输入b.ascx或c.ascx 1. TestA.ascx: 2. a.ascx: ... 阅读全文

MDI窗体,子窗体在父窗体中最大化,如果子窗体已经打开则显示,不重复打开窗体

2008-04-17 13:11 by Virus-BeautyCode, 3960 阅读, 收藏, 编辑
摘要: Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using Syst... 阅读全文

.NET中的winform的listview控件

2008-04-11 09:07 by Virus-BeautyCode, 3940 阅读, 收藏, 编辑
摘要: Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->ListViewItem lvItem1 = new ListViewItem(); lvItem1.SubItems.Clear(); lvItem1.Sub... 阅读全文

winform+c#之窗体之间的传值

2008-03-31 15:27 by Virus-BeautyCode, 10750 阅读, 收藏, 编辑
摘要: 窗体传值可以分为两类。1、主窗体往子窗体传值有两种方法,一种是在子窗体提供重载构造函数,利用重载构造函数传递值,适用于传值数量比较少;第二种是,在子窗体中定义一个主窗体对象,然后就可以接收到主窗体的属性值了,适用于传值数量大。主窗体代码如下: public partial class frmParent : Form { private string strValueA =... 阅读全文

C#.NET禁止一个程序启动多个实例

2008-03-26 09:20 by Virus-BeautyCode, 1712 阅读, 收藏, 编辑
摘要: 在Program.cs中添加如下代码: Boolean createdNew; //返回是否赋予了使用线程的互斥体初始所属权 System.Threading.Mutex instance = new System.Threading.Mutex(true, "MutexName", out createdNew); //同步基元变量 ... 阅读全文

动态调用c++的dll

2008-03-26 09:03 by Virus-BeautyCode, 702 阅读, 收藏, 编辑
摘要: 是我在论坛看到的一个例子,所以记录下来,以后用到可以参考。[DllImport("Kernel32.dll")]public static extern int LoadLibrary(String funcname);[DllImport("Kernel32.dll")]public static extern int GetProcAddress(int handle, String func... 阅读全文

【转载】用反射来解决字段多带来的烦恼

2008-03-24 10:41 by Virus-BeautyCode, 521 阅读, 收藏, 编辑
摘要: 文章是我转载的,地址是:http://www.cnblogs.com/snryang/archive/2008/03/22/1117974.html 做项目开发的时候,大家应该经常都会遇到一个表里面的很多个字段的情况吧.在之前我接触的一个项目,有一个表有20多个字段.要向表中添加记录,和将一条数据绑定到页面上都要写很多代码.如: 下面是一个用户表的添加 User user ... 阅读全文

封装原来的DirectoryInfo类,添加事件,可以代替FileSystemWatcher 类

2007-09-29 17:24 by Virus-BeautyCode, 653 阅读, 收藏, 编辑
摘要: using System;using System.IO;//封装原来的DirectoryInfo类,添加事件,可以代替FileSystemWatcher 类public class DirectoryInfoNotify{ public DirectoryInfoNotify(string path) { internalDirInfo = new DirectoryI... 阅读全文

[原创]socket,c#,.net,dns,client,server,console

2007-09-19 09:29 by Virus-BeautyCode, 1144 阅读, 收藏, 编辑
摘要: client//................................................................................using System;using System.Collections.Generic;using System.Text;using System.Net;using System.Net.Sockets;namesp... 阅读全文

[原创]异步,跨线程,非阻塞,DNS,Socket

2007-09-18 16:07 by Virus-BeautyCode, 867 阅读, 收藏, 编辑
摘要: Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Dr... 阅读全文