C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » DataGridView »

Verify any of the checkbox is selected in a checkbox column of Datagridview


Posted Date: 17 May 2009    Resource Type: Code Snippets    Category: DataGridView
Author: Muralidharan RangarajuMember Level: Gold    
Rating: 1 out of 5Points: 8



If we have checkbox column in datagridview, we may have to check whether any of the checkbox is selected on an click event. In that case this function will be usefull.Logic for the snippet is given in the comment itself.

//To verify whether a checkbox is selected in checkbox column of a datagridview

private bool checkIsRowSelected(DataGridView dg)
{
bool isRowSelected = false;
//Loop through each row of datagridview
foreach (DataGridViewRow check in dg.Rows)
{
//Assume first column is checkbox column
if (check.Cells[0].Value != null)
{
//Get the value in a string
string chkValue = check.Cells[0].Value.ToString();
if (chkValue != "0" && chkValue != "False")
{
//if any of the row is selected, change the value of bool variable
isRowSelected = true;
break;
}
}
}
//return the value
return isRowSelected;
}



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Datagridview checkbox column  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Export DataGridView into .csv file
Previous Resource: Disable CheckBoxes in a CheckBox Column of DataGridView Control
Return to Discussion Resource Index
Post New Resource
Category: DataGridView


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use