cbUserAgent是一个combox ArrayList list = new ArrayList(); Dictionary<string, string> useragents = new Dictionary<string, string>(); /// <summary> /// 初始化combox /// </summary> private void InitCbUserAgent() { cbUserAgent.Items.Clear();…
最近将一个项目从ASP.NET MVC 3升级至刚刚发布的ASP.NET MVC 5.1,升级后发现一个ajax请求出现了500错误,日志中记录的详细异常信息如下: System.ArgumentException: 已添加了具有相同键的项.(An item with the same key has already been added) 在 System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boole…
HTTP模拟工具 开发语言:C#/Winform开发工具:Visual Studio 2017数据库:   SQLite使用框架:界面-MetroModernUI              Http请求-RestSharp              ORM-Dapper.Net              Json解析-Newtonsoft.Json              多线程-SmartThreadPool本来打算试一下Dapper.Net扩展框架-DapperExtensions,用了有…
今天WINFROM编程遇到这么一个问题:是有关WINFORM中两个comboBox控件绑定同一个数据源的问题,在窗体的界面上有两个comboBox,我在Form1_Load中对他们做了数据绑定(具体代码如下),但是运行出现了这个一个奇怪的问题,我改变了comboBox1的值,但是comboBox2的值也自动改变了,我没有设置comboBox1_SelectedIndexChanged函数 private void Form1_Load(object sender, EventArgs e) {…
最近做了一个winform的项目,数据绑定在datagridview中,datagridview中的数据需要删除,分页,更新等之类的操作,所以就涉及到了datagridview的重新绑定问题,而且这些操作都是使用的多线程. 问题:有的时候DataGridView的DataSource会报错 NullReferenceExcepti,甚至在程序入口处报错,提示NullReferenceExcepti.如下图(报错的时候忘了截图了,就是这个位置) 或者 分析:经过仔细的验证和分析,这种错误是多线程引…
开发中需要根据下拉框的选择处理一些业务逻辑,使用ID值或Text值都不利于代码维护,所以可以写个扩展方法绑定到枚举上. public static class Extensions { /// <summary> /// 绑定ComboBoxEx数据源到枚举类型 /// </summary> /// <param name="cmb"></param> /// <param name="enumType">…
1. 在用List<T>对象绑定DataGridView数据源属性的时候,数据源的内容不会动态更新,如果List<T>对象集合中的数据发生变化,那么数据控件的数据源是不会得到更新的. 一般也不建议用List<T>去填充数据显示控件的数据源. 如果一定要用List<T>对象去绑定数据源,那么首先设置DataGridView的DataSource属性为new List<T>(),然后再将List<T>集合重新赋值给DataSource属性…
public static class ComponentHelper<T> where T : Control { public static bool HaveEventHandler(T control, string eventName, string methodName) { //获取Button类定义的所有事件的信息 PropertyInfo pi = (typeof(T)).GetProperty("Events", BindingFlags.Instanc…
首先我要读取这个excel文件然后生成Datable 用winform编程的方式 前台界面: 后台的代码 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.…
将集合数据绑定到ListBox和ComboBox控件,界面上显示某个属性的内容 //... //自定义了Person类(有Name,Age,Heigth等属性) List<Person> persons=new List<Person>(); persons.Add(,)); persons.Add(,)); persons.Add(,)); //ListBox控件实现 lb_PersonsList.DataSource=persons; //指定数据源 lb_PersonList…