Click here to Skip to main content
12,509,081 members (57,182 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#3.5
Can anybody tell me how to check richtextbox empty in c# 3.5
Please if anybody knows the answer then reply back soon
Posted 12-Feb-12 21:26pm
sss25345
Comments
shripk 13-Feb-12 3:35am
   
Its in C# version 4 and I need in version 3.5
shripk 13-Feb-12 5:46am
   
I ve tried that but still not getting...
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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[^].
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

As simple as that .

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.
  Permalink  
Comments
shripk 13-Feb-12 6:46am
   
I ve tried this bfr only but still m not getting it.
Rahul Dhoble 13-Feb-12 7:09am
   
Let me know your code then ?
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160927.1 | Last Updated 27 Jun 2014
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100