.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Windows Application >> Post New QuestionBookmark and Share Subscribe to Forum

Set Error Provider for Datagridview in C#.net

Posted By: Narayanan     Posted Date: January 25, 2013    Points:5   Category :Windows Application
Hi All,
How to set Error Provider for Datagridview when Row is empty? I am working on Windows Application.

Responses
Author: Narayanan             
Posted Date: January 27, 2013     Points: 20   

This is a method for finding Datagridview Row Empty
 static bool rowIsEmpty = true;
public static bool CheckRowEmpty(DataGridView DGV)
{
if (DGV.Rows[0].Cells.Count > 0)
{


foreach (DataGridViewCell cell in DGV.Rows[0].Cells)
{
if (cell.Value != null)
{
rowIsEmpty = false;
break;
}
else
{
rowIsEmpty = true;
break;
}
}
}
return rowIsEmpty;
}



Call this Method in your Datagridview Application .

     if (CheckRowEmpty(datagridview1))
{
ErrProvider1.SetError(datagridview1, "Please Fill Information in the Datagridview");
}
else
{
ErrProvider1.SetError(datagridview1, "");
}



Regards, Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend