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...






Forums » .NET » Windows »

Validating datagridview column


Posted Date: 01 Jan 2009      Posted By: sreejith      Member Level: Gold     Points: 1   Responses: 3



In my windows application(c# ,2005),i am using a datagridview .In that datagridview i ve some fields where user can enter only integer value for each row.How to do it?Please help me




Responses

Author: Deepika Haridas    01 Jan 2009Member Level: DiamondRating: 1 out of 5     Points: 1

Hi,

Check this link

http://msdn.microsoft.com/en-us/library/ms972948.aspx



Thanks & Regards,
Deepika
Editor

If U want to shine like a SUN..First U have to burn like the SUN!!
Need a Guide? Join my mentor program..



Author: Ranish    02 Jan 2009Member Level: BronzeRating: 2 out of 52 out of 5     Points: 2

private void dgdSubject_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
TextBox innerTextBox;

if (e.Control is TextBox)
{

innerTextBox = e.Control as TextBox;
innerTextBox.KeyPress += new KeyPressEventHandler(innerTextBox_KeyPress);

}
}



private void innerTextBox_KeyPress(object sender, KeyPressEventArgs e)
{

if (!Char.IsControl(e.KeyChar))
{
if (Char.IsDigit(e.KeyChar))
{
if (Convert.ToInt16(((TextBox)sender).Text + e.KeyChar.ToString()) >= 10)
{
e.Handled = true;
}
}
else
{
e.Handled = true;
}

}

}



Author: sreejith    02 Jan 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 0

If I am having more than one textbox then what ll i do?


Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : textbox validation
Previous : Third party control
Return to Discussion Forum
Post New Message
Category: Windows

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use