当我单击Datagridviewcheckboxcolumn时如何捕获 [英] how can i trap when i click in Datagridviewcheckboxcolumn

查看:53
本文介绍了当我单击Datagridviewcheckboxcolumn时如何捕获的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在datagridview控件中为Datagridviewcheckboxcolumn捕获事件?当我单击它时,

How can i trap i event for Datagridviewcheckboxcolumn in a datagridview control? when i click it,
how can i get it checked or unchecked?

推荐答案

我有一个名为gridPassenger的datagridview,带有一个名为dgAllowCreditJourneys的复选框.这是我的cellvaluechanged事件的片段:

I have a datagridview called gridPassenger with a checkbox column called dgAllowCreditJourneys. Heres a snipped from my cellvaluechanged event:

if (e->ColumnIndex == dgAllowCreditJourneys->Index)
{
	if ((bool)gridPassenger->Rows[e->RowIndex]->Cells[dgAllowCreditJourneys->Index]->Value != chkAllowCreditJourneys->Checked)
	{
		chkAllowCreditJourneys->Checked = (bool)gridPassenger->Rows[e->RowIndex]->Cells[this->dgAllowCreditJourneys->Name]->Value;
		m_ElementList = m_ElementList | m_FlagBits::ALLOWCREDITJOURNEYS;
	}
}



因此,仅当刚编辑的单元格是我的复选框列时,"if"才会出现.它的值保存在



So the ''if'' only kicks in when the cell just edited is my checkbox column. Its value is held in

(bool)gridPassenger->Rows[e->RowIndex]->Cells[dgAllowCreditJourneys->Index]->Value

中,该示例让我首先对照表单上的另一个复选框对其进行检查,并且在不同之处,我将该值从datagridview复选框复制到了另一个复选框.我还设置了一个标志,以指出发生了更改.

一件事,我的代码是C ++/CLI,但通常如果将

and the example has me first checking it against another checkbox on the form and where differant, I copy the value from the datagridview checkbox to the other one. I also set a flag to note that a change has occurred.

One thing, my code is C++/CLI but in general if you replace

->

替换为

.

,它将转换过来.


这篇关于当我单击Datagridviewcheckboxcolumn时如何捕获的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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