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 22: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 OriginalGriff 406
1 /\jmot 180
2 Suraj Sahoo | Coding Passion 170
3 Afzaal Ahmad Zeeshan 159
4 BillWoodruff 154
0 OriginalGriff 8,344
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,634
3 Maciej Los 5,024
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.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