Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can anybody tell me how to check richtextbox empty in c# 3.5
Please if anybody knows the answer then reply back soon
Posted
Comments
sss25 13-Feb-12 3:35am    
Its in C# version 4 and I need in version 3.5
sss25 13-Feb-12 5:46am    
I ve tried that but still not getting...

Try this code
public bool isRichTextBoxEmpty()
{
    TextPointer startPointer = MyRTB1.ContentStart.GetNextInsertionPosition(LogicalDirection.Forward);
    TextPointer endPointer = MyRTB1.ContentEnd.GetNextInsertionPosition(LogicalDirection.Backward);
    if (startPointer.CompareTo(endPointer) == 0)
        return true;
    else
        return false;
}


I picked this up from here[^].
 
Share this answer
 
As simple as that .

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CP_329218_How_to_check_empty_for_richtextbox_in_csharp_3_5
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (richTextBox1.Text !=String.Empty)
            MessageBox.Show(richTextBox1.Text);
        }
    }
}



Hope this helps if yes then accept and vote the answer otherwise revert back with your queries
--Rahul D.
 
Share this answer
 
Comments
sss25 13-Feb-12 6:46am    
I ve tried this bfr only but still m not getting it.
RDBurmon 13-Feb-12 7:09am    
Let me know your code then ?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900