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 » C# Syntax »

How to handle the cell edit event in the DataGridView


Posted Date: 14 Oct 2009    Resource Type: Code Snippets    Category: C# Syntax
Author: KunalMember Level: Gold    
Rating: 1 out of 5Points: 2



If you want to clear the data in one column when there is data in the other column e.g. in case of account software say two cols in the datagrid called Debit and Credit. Now the problem is every row either can have debit or credit. How to go about it. assume the column nos are 0 and 1 resp and assume textbox cols for both debit and credit

We should handle the CellEndEdit event of the datagridvirw


<font color=blue>
private void DataGridView1_CellEndEdit(object sender,DataGridViewCellEventArgs e)
{
if(e.ColumnIndex==0)
{
DataGridView1.Rows[e.RowIndex].Cells[1].Value = String.Empty;
}
else if(e.ColumnIndex==1)
{
DataGridView1.Rows[e.RowIndex].Cells[0].Value = String.Empty;
}

}
</font>




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.
Handle cell edit event in datagridview  .  

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: Print more then one copies of Crystal reports
Previous Resource: WPF - Binding DataTable to a WPF Datagrid
Return to Discussion Resource Index
Post New Resource
Category: C# Syntax


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use