C#Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
Hi
I am completely new to c# .so i am just into basics.
just now i am beginning to work with windows forms
now i have to add a text box and a insert button
now when iam entering the text it should be inserted when the button is clicked.
now wht i need is that when the text box is empty and when i clicked the button , it should show a message saying that textbox is empty
I Think this is very smalll problem. But as iam new, pls guide me to do it .
You need to test the length of the text in the textbox
Your textbox has a 'Text' attribute, as well as others.
The Text is of the type 'string' and strings have many attributes, one of wich is Length.
You need to test that Length is greater than zero.
So if your Textbox is called TextBox1, in the onclick event of the button you test like so.
if(TextBox1.Text.Length <= 0)
{
//Show the message
MessageBox.Show("You Messaage");
}
else
{
//Do whatever else you wanted to do
}
I have ot used C# windows for a while so Im not sure syntax is exact, especially the messagebox.show bit.
But that should be a start.
======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
Actually it should be <= not <
I've edited the post
======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================