从.net控件中的datagridview中重写值 [英] Retrive Value from datagridview in .net controls

查看:90
本文介绍了从.net控件中的datagridview中重写值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从gridview单元格中检索一个值并在checklistbox中填写该值,以便如何在cheklistbox中填充该数据..?

解决方案

你可以按如下方式进行:

  //  点击事件of datagrid  
private void datagrid_CellClick(System。 Object sender,System.Windows.Forms.DataGridViewCellEventArgs e)
{
string val = ;
// 如果点击了数据网格行的单元格,那么
if (e.RowIndex > -1& e.ColumnIndex > ; -1){
val = this .datagrid.Rows(e.RowIndex).Cells( 2 )值。
// 2是数据网格的列索引
// 检查您的逻辑
如果 (val == ram){
this .checkList.Items( 1 )。@ checked = true ;
}

}
}





评论任何进一步的查询。


I want to retrive a value from a gridview cell click and fill that value in checklistbox so how can i fill that data in cheklistbox.. ?

解决方案

You can proceed as follows :

//on click event of datagrid
private void datagrid_CellClick(System.Object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
{
	string val = null;
	//if cell of data grid row is clicked then
	if (e.RowIndex > -1 & e.ColumnIndex > -1) {
		val = this.datagrid.Rows(e.RowIndex).Cells(2).Value;
		//2 is your column index of data grid
		// Check As of your logic
		if (val == "ram") {
			this.checkList.Items(1).@checked = true;
		}

	}
}



comment for any further queries.


这篇关于从.net控件中的datagridview中重写值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆