954,152 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Datagridview control

Hi,
In my Datagridview contains itemno,itemdescription,quantity,price columns.
this values can view in crystal report.in crystal report only 10 colums can able to view.
so,in item descriptionin cell only 10 lines i have to enter .if it is more than that i want to display messagebox and chance is there for only one item description contails more than 10 lines.In this situation also i want to display error message.

sireesha.c
Newbie Poster
17 posts since May 2008
Reputation Points: 10
Solved Threads: 0
 

Just get the description textbox user enters description into and pass it.

int HowManyOccurance(string str, char charToSearchFor)
        {
            int numberOfOccurance = 0;
            CharEnumerator ce = str.GetEnumerator();
            while(ce.MoveNext())
            {
                if (ce.Current == charToSearchFor)
                    numberOfOccurance++;
            }
            return numberOfOccurance;
        }

{
if(HowManyOccurance(yourTextBox.Text, '\n') <=10)
MessageBox.Show("Correct");
else
MessageBox.Show("Please make it shorter, just 10 lines permitted");
}
Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
 

Just get the description textbox user enters description into and pass it.

int HowManyOccurance(string str, char charToSearchFor)
        {
            int numberOfOccurance = 0;
            CharEnumerator ce = str.GetEnumerator();
            while(ce.MoveNext())
            {
                if (ce.Current == charToSearchFor)
                    numberOfOccurance++;
            }
            return numberOfOccurance;
        }

{
if(HowManyOccurance(yourTextBox.Text, '\n') <=10)
MessageBox.Show("Correct");
else
MessageBox.Show("Please make it shorter, just 10 lines permitted");
}


private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
TextBox txt=e.Control as TextBox;
txt.TextChanged +=new EventHandler(txt_TextChanged);
}

void txt_TextChanged(object sender, EventArgs e)
{

}


in text changed event i have to find number of lines and number of character i entered.
plz help me.

sireesha.c
Newbie Poster
17 posts since May 2008
Reputation Points: 10
Solved Threads: 0
 
void txt_TextChanged(object sender, EventArgs e)
{
if(HowManyOccurance(yourTextBox.Text, '\n') <=10)MessageBox.Show("Correct");elseMessageBox.Show("Please make it shorter, just 10 lines permitted");}int HowManyOccurance(string str, char charToSearchFor)
        {
            int numberOfOccurance = 0;
            CharEnumerator ce = str.GetEnumerator();
            while(ce.MoveNext())
            {
                if (ce.Current == charToSearchFor)
                    numberOfOccurance++;
            }
            return numberOfOccurance;
        }

{
if(HowManyOccurance(yourTextBox.Text, '\n') <=10)
MessageBox.Show("Correct");
else
MessageBox.Show("Please make it shorter, just 10 lines permitted");
}
}
Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You