Click here to Skip to main content
11,713,845 members (87,583 online)
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 370
1 CHill60 250
2 Maciej Los 229
3 Richard MacCutchan 210
4 OriginalGriff 175
0 Sergey Alexandrovich Kryukov 365
1 CHill60 335
2 OriginalGriff 245
3 Andy Lanng 173
4 Richard MacCutchan 150


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