i want to delete row from datagrid view when all row column get 0

i have 6   to 7 column in datagrid view in that 1st column name is "name" 2nd to 7th all have some  numeric values i want to delete row when that numeric values get 0 in windows form C#
sagar shedgeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
Do you think what to do the manipulation from your Data Source instead of DataGridView?
0
sagar shedgeAuthor Commented:
no it must be get disable or delete from data grid view only
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
"delete" means it was generated, and then somehow it was "removed". it's the same in some sense that we exclude it before it's being generated. That's my idea.
0
Prakash SamariyaIT ProfessionalCommented:
2nd to 7th all have some  numeric values i want to delete row when that numeric values get 0 in windows form C#

When all column has 0 value?
If Yes, then please find below code (not tested)
//Delete ROW if all columns empty
void DataGridView_RowDataBound(Object sender, GridViewRowEventArgs e)
{
	if(e.Row.RowType == DataControlRowType.DataRow)
	{
		var isZero = true;
		//Loop Starts from 1 as First column (Name) needs to be omit
		for(int i=1;e.Row.Cells.Count;i++)
		{
			if(!String.IsNullOrEmpty(e.Row.Cells[i].Text)
				isZero = false;
		}

		//Delete ROW - If all rest of all columns empty
		if(isZero)
		{
			  DataGridView.DeleteRow(e.Row.RowIndex) 
		}
	}
}

Open in new window

OR When any column has 0 value?
If Yes, then please find below code change in above function(not tested)
//Change below logic in above code to 
//Delete ROW if any columns (except first) empty
var isZero = false;
//Loop Starts from 1 as First column (Name) needs to be omit
for(int i=1;e.Row.Cells.Count;i++)
{
	if(String.IsNullOrEmpty(e.Row.Cells[i].Text)
	{	
		isZero = true; break;
	}
}

Open in new window

NOTE: I have made condition for to check cell value is empty or not, you can change it to check for "0"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
frankhelkCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Accept: Prakash Samariya (https:#a42062950)

If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

frankhelk
Experts-Exchange Cleanup Volunteer
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.