Yes, that worked...
Sorry but anyway I'm stuck now - how do I determine status (true/false) of this checkbox? I'm really capable of reading, I have MSDN installed...I just cannot find it.
Main Topics
Browse All TopicsHello!
I got a DataGridView, one column is set to checkbox. I want to grab event when those checkbox are being clicked on. Currently I'm trying to do it via CellContentClick, but I have no idea how to cast from (DataGridViewCellEventArgs
Thanks,
Grzegorz
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I also think this should work...but it simply doesn't!
My current code is:
private: System::Void clc(System::Object^ sender, System::Windows::Forms::Da
if(e->ColumnIndex == 0) {
DataGridViewCell^ cell = this->dataGridView1->Rows[
DataGridViewCheckBoxCell^ checkCell = (DataGridViewCheckBoxCell^
bool checked = false;
if((checkCell != nullptr)&&(checkCell->Valu
checked = (bool)checkCell->Value;
}
if(checked) {
MessageBox::Show("yeah!");
}
}
}
The behaviour is very strange for me. Sometimes it always shows messagebox, sometimes never. I guess that it is bad event that I put this code on (CellContentClick) but msdn says:
,,If you want to respond immediately when users click a check box cell, you can handle the DataGridView.CellContentCl
I don't understand.
BTW, you can get much more information about DataGridView in C# or VB .NET area. Such things are usually written in C# or VB. C++/CLI is used mostly for interoperability.
If you have some reasons to do this stuff in C++/CLI, you can ask syntax questions here, and general questions about database, controls like DataGridView in other .NET areas. C++/CLI developers don't work with this.
Updated Comment
***********************
private void dgv_CellContentClick(objec
{
DataGridView dgv = sender as DataGridView;
DataGridViewCell cell = dgv.Rows[e.RowIndex].Cells
bool isChecked = (bool)cell.EditedFormatted
if (isChecked)
{
//Checkbox is being checked
}
else
{
//Checkbox is being unchecked
}
}
Business Accounts
Answer for Membership
by: AlexFMPosted on 2006-11-23 at 11:30:08ID: 18004410
C# code from MSDN samples looks like this:
lick(objec t sender, DataGridViewCellEventArgs e) dex].Cells [e.ColumnI ndex];
cell;
lick(Objec t^ sender, DataGridViewCellEventArgs^ e) Index]->Ce lls[e->Col umnIndex];
)cell;
private void DataGridView1_CellContentC
{
DataGridViewCell cell = DataGridView1.Rows[e.RowIn
}
I think that DataGridViewCheckboxCell can be get by casting:
DataGridViewCheckboxCell checkCell = (DataGridViewCheckboxCell)
In C++/CLI this can look like this:
private void DataGridView1_CellContentC
{
DataGridViewCell^ cell = DataGridView1->Rows[e->Row
DataGridViewCheckboxCell^ checkCell = (DataGridViewCheckboxCell^
}