Click here to Skip to main content
Rate this: bad
good
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 at 13-Feb-12 3:35am
   
Its in C# version 4 and I need in version 3.5
shripk at 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 at 13-Feb-12 6:46am
   
I ve tried this bfr only but still m not getting it.
Rahul Dhoble at 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
0 Sergey Alexandrovich Kryukov 363
1 OriginalGriff 354
2 George Jonsson 248
3 Shemeemsha RA 148
4 Animesh Datta 130
0 OriginalGriff 6,179
1 Sergey Alexandrovich Kryukov 5,616
2 CPallini 4,770
3 George Jonsson 3,400
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 27 Jun 2014
Copyright © CodeProject, 1999-2014
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