我有一个产品类
还定义了一个泛型集合
public List<ProductInfo> myproducts = new List<ProductInfo>();
我的窗体中this.dataGridView3.DataSource = mycollection.myproducts.ToArray();
那么我想要选择dataGridView3中的某一行对泛型里的数据进行更新和删除
不知道怎么做!
还定义了一个泛型集合
public List<ProductInfo> myproducts = new List<ProductInfo>();
我的窗体中this.dataGridView3.DataSource = mycollection.myproducts.ToArray();
那么我想要选择dataGridView3中的某一行对泛型里的数据进行更新和删除
不知道怎么做!
解决方案 »
- 清空C# Winform里的DataGridView中的结构和数据
- if如何判断变量之中是否带有数字
- C++动态库被C#调用中,动态库中执行了析构函数就抛出“Invalid Address specified to RtlFreeHeap”错误
- 如何在后台把Repeater的某一列的特定的值传给一个变量?
- Serialize问题
- 范型数值跟数值的普通应用速度相比如何?
- 你们的C#都有智能感知吗,为什么我这个不灵呢???
- 后台数据更新
- C#中如何使得form1和form3传递事件问题
- 急!求助一个滚动条控件窗口写法! 小数点类型
- 求各位大虾帮忙,正则表达式基本上还给老师了.在线等!
- 获取打开网站时候发送的请求包
当然ProductInfo类要加入[Serializable]标识可序列化
dataGridView1.Rows[dataGridView1.CurrentRow.Index ].Cells["id"].Value
查询获取实体对象
int index = myproducts.IndexOf(pi);//第index个
元素就是pi
ProductInfo[]是null
不好说吧
我把数据都存进这里了
最后在填到数据库里
{
DataGridView d = new DataGridView();
this.Controls.Add(d);
List<aa> list = new List<aa>();
list.Add(new aa("abc", 0));
list.Add(new aa("def", 1));
d.DataSource = list;
d.Rows[0].Selected = true;
aa obj = (d.DataSource as List<aa>)[d.SelectedRows[0].Index];
}public class aa
{
public string Name { get; set; }
public int Age { get; set; }
public aa()
{
Name = "aa";
Age = 0;
}
public aa(string n, int a)
{
Name = n;
Age = a;
}
}
ProductInfo p = (this.dataGridView3.DataSource as List<ProductInfo>) [dataGridView3.SelectedRows[0].Index];
这个能详细说明一下吗?