随笔分类 -  C#

摘要:一.silverlight与silverlight中可以利用委托(delegate)来刷新frame.Refresh()1.在子类中定义委托捕捉关闭事件按钮 1 public delegate void onCloseClick(object sender, RoutedEventA... 阅读全文
posted @ 2014-05-28 13:44 银河系上的地球 阅读(256) 评论(0) 推荐(0)
摘要:1.此方法将会刷新到主页面1 private void btn_Click(object sender, RoutedEventArgs e)2 {3 4 HtmlPage.Window.Eval("window.location.reload();");5 6 }Vi... 阅读全文
posted @ 2014-05-23 18:52 银河系上的地球 阅读(291) 评论(0) 推荐(0)
摘要:1.上传 1 private void Button_Click_1(object sender, RoutedEventArgs e) 2 { 3 OpenFileDialog openFileDialog = new OpenFileDialog() 4... 阅读全文
posted @ 2014-05-23 13:44 银河系上的地球 阅读(986) 评论(0) 推荐(0)
摘要:1.第一个参数(3.1415926)是要处理的数值、第二个参数(1)为要保留的几位小数、第三个参数是按照“四舍五入”还是"直接取这一位的值"(MidpointRounding.ToEven:四舍五入)Math.Round(3.1415926, 1, MidpointRounding.ToEven); 阅读全文
posted @ 2014-05-07 16:02 银河系上的地球 阅读(2696) 评论(0) 推荐(0)
摘要:public void RandSort(int[] _num) { Random rd = new Random(); int temp = 0, tempNum = 0; for (int i = 0; i < _... 阅读全文
posted @ 2014-05-07 14:16 银河系上的地球 阅读(516) 评论(0) 推荐(0)
摘要:private void txtName_KeyDown(object sender, KeyEventArgs e) { Regex rg = new Regex("^[\u4e00-\u9fa5\b]$"); //\b是退格键 ... 阅读全文
posted @ 2014-04-29 15:47 银河系上的地球 阅读(136) 评论(0) 推荐(0)
摘要:void mobile_KeyUp(object sender, KeyEventArgs e) { Regex rg = new Regex("^[0-9]{1,11}$"); Regex rg1 = new Regex("\b"); ... 阅读全文
posted @ 2014-04-29 15:46 银河系上的地球 阅读(266) 评论(0) 推荐(0)
摘要:问题:当点击全选时,全选所有的复选框,但是滚动屏幕时,却复选框就会取消选中一、解决方法(将要展示的实体数据模型添加bool属性,在数据绑定时添加click时间,盘带选中的状态,就可以了)1. xaml 1 2 3 4 ... 阅读全文
posted @ 2014-04-21 13:51 银河系上的地球 阅读(304) 评论(0) 推荐(0)
摘要:1.文件压缩事件 private void button1_Click(object sender, EventArgs e) { string[] FileProperties = new string[2]; FileProperties... 阅读全文
posted @ 2014-04-19 17:28 银河系上的地球 阅读(241) 评论(0) 推荐(0)
摘要:public bool Send() { //mail message MailMessage myMail = new MailMessage(); myMail.From = new MailAddress("12... 阅读全文
posted @ 2014-04-19 17:24 银河系上的地球 阅读(209) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2014-03-07 09:27 银河系上的地球 阅读(142) 评论(0) 推荐(0)
摘要:今天WINFROM编程遇到这么一个问题:是有关WINFORM中两个comboBox控件绑定同一个数据源的问题,在窗体的界面上有两个comboBox,我在Form1_Load中对他们做了数据绑定(具体代码如下),但是运行出现了这个一个奇怪的问题,我改变了comboBox1的值,但是comboBox2的值也自动改变了,我没有设置comboBox1_SelectedIndexChanged函数 1 private void Form1_Load(object sender, EventArgs e) 2 { 3 dataset ds=getds("select code,name from 阅读全文
posted @ 2014-03-03 15:06 银河系上的地球 阅读(618) 评论(0) 推荐(0)
摘要:static void Main(string[] args) { int[] numbers = new int[] { 3, 2, 21, 3, 3, 23, 4, 43, 23, 23 }; Array.Sort(numbers); Array.ForEach(numbers,Msg);// (i) => Console.WriteLine(i)); Console.ReadKey(); } static void Msg(int ... 阅读全文
posted @ 2014-02-28 14:23 银河系上的地球 阅读(373) 评论(0) 推荐(0)
摘要:1.下面两个文件.xls是给的文件,实际上是.xml文件2.具体的代码 1 private void btOK_Click(object sender, EventArgs e) 2 { 3 //0.获取路径文件夹 4 this.btOK.Enabled = false; 5 this.textBox1.Text = System.Windows.Forms.Application.StartupPath + "\\de"; 6 strAllFiles = Directory.Ge... 阅读全文
posted @ 2014-02-28 11:53 银河系上的地球 阅读(1034) 评论(0) 推荐(0)
摘要:1.声明变量 #region "声明变量" /// /// 写入INI文件 /// /// 节点名称[如[TypeName]] /// 键 /// 值 /// 文件路径 /// [DllImport("kernel32")] private static extern long WritePrivateProfileString(string section, string key, string val, string filepath); ... 阅读全文
posted @ 2014-02-14 15:51 银河系上的地球 阅读(322) 评论(0) 推荐(0)
摘要:提供者:porschev题目:下列数据放在一个List中,当ID和Name都相同时,去掉重复数据ID Name 1 张三 1 李三 1 小伟 1 李三 2 李四 2 李武------------------------------------------------------------------------------------------------------------解决这个问题,方法很多,最开始想到的就Enumerable.Distinct方法我们可能经常用的是Distinct(IEnumerable)用它对数组这一类去重复这里要用Distinct(IEnumerable, 阅读全文
posted @ 2014-01-10 10:12 银河系上的地球 阅读(200) 评论(0) 推荐(0)
摘要:这里假定只有两级节点,多级方法类似。遍历节点,根据选中节点文本找到要选中的节点。treeView.SelectedNode = selectNode; 1 /// 2 /// 设置TreeView选中节点 3 /// 4 /// 5 /// 选中节点文本 6 private void SelectTreeView(TreeView treeView, string selectStr) 7 { 8 treeView.Focus(); 9 for (int i = 0; i < treeView.Nodes.Count; i++)10 {11 for... 阅读全文
posted @ 2013-10-24 10:38 银河系上的地球 阅读(1435) 评论(0) 推荐(0)
摘要:问题:类型“System.ComponentModel.ISupportInitialize”在未被引用的程序集中定义。必须添加对程序集“System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”的引用答案:在工程引用目录上点击右键添加System类库的引用就行了。 阅读全文
posted @ 2013-09-26 09:04 银河系上的地球 阅读(977) 评论(0) 推荐(0)
摘要:(一)将汉字转化成全拼代码:1 private void button1_Click(object sender, EventArgs e)2 {3 this.textBox2.Text = Hz2Py.Convert(this.textBox1.Text);4 }View Code 汉字转拼音类: 1 /// 2 /// 汉字转拼音类 3 /// 4 public class Hz2Py 5 { 6 private static int[] pyValue = new int[] 7 ... 阅读全文
posted @ 2013-09-02 23:43 银河系上的地球 阅读(994) 评论(0) 推荐(0)
摘要:1 private long fileLength; 2 3 private long downLength;//已经下载文件大小,外面想用就改成公共属性 4 5 private static bool stopDown; 6 7 public HttpDownLoad() 8 9 { 10 11 fileLength = 0; 12 13 downLength = 0; 14 15 stopDown = false; 16 17 // 18 19 // TODO: 在此处添加构造函数逻辑 20 21... 阅读全文
posted @ 2013-09-02 23:29 银河系上的地球 阅读(1030) 评论(0) 推荐(0)