CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2012
    Posts
    3

    If richtextbox is empty to display a msgbox

    if i press for example button1, and i want it to have a statement,


    button1.

    if richtextbox 1 = "" then,
    msgbox1. "you have no text".

    how do you do this in c#?

    I USE VISUAL C# 2010 EXPRESS!
    Last edited by tambovskya; June 14th, 2012 at 02:49 PM.

  2. #2
    Join Date
    Jun 2012
    Posts
    3

    Re: If richtextbox is empty to display a msgbox

    also one more question, how would i code that, example,

    if richtextbox 1 contains word "like",
    then change that word to "whatever"

  3. #3
    Join Date
    Jun 2012
    Posts
    3

    Re: If richtextbox is empty to display a msgbox

    Also is it possible to do this?

    for example,

    if richtextbox1 contains word "because", then
    change it to any of these words,

    example,
    example,
    example,

    and random selector.

  4. #4
    Join Date
    Nov 2011
    Posts
    36

    Re: If richtextbox is empty to display a msgbox

    I use this for a textbox, pretty sure it's close to the same as a rich text box.

    Code:
    if (String.IsNullOrEmpty(textbox.Text))
                    MessageBox.Show("No text detected, please enter something!");
    else
    {
         //Whatever you want it to do after it's no longer empty.
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured