Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. RichTextBox control refuses to update to reflect changes.

RichTextBox control refuses to update to reflect changes.

Scheduled Pinned Locked Moved C#
helpwinformsgraphicsquestionannouncement
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SawmillTurtle
    wrote on last edited by
    #1

    I've been writing this rental property management program for my landlord for awhile now. I decided to rewrite the section which allows for the creation of custom leases from scratch, because it was far beyond saving. It was overly complicated and bloated; it twisted and weaved through a maze of classes and function calls; it relied heavily upon another class library, which was also unnecessary. We all have to learn sometime, yes? Anyway, I've written a simple class with a form to replace it. It has a listbox which is supposed to keep track of individual sections. It has an RTF box for the actual text and a heading box for the title of each section. There are also formatting buttons and a linklabel that opens a Font Select dialog box. The listbox is bound to a datasource, and the datasource is a BindingList made up of the section titles. The problem is that when I have nothing in the listbox and format the text in the RTF control, the formatting appears. Bold text appears when I hit the "B" button, italics show up when I hit the "I" button, and so on. When I use the context menu to add an entry to the datasource, this no longer happens. The formatting stops working. By using tracing and break points, I can see that it seems to be working. When I watch rtfLeaseText.SelectionFont after hitting the "B", for instance, the "Bold" boolean value is set to true. This is not reflected in the text displayed. I can't imagine why this would be. I'll paste the code below. If someone can help, I'd greatly appreciate it. EDIT: Updated code to reflect changes.

    using System;
    using System.Drawing;
    using System.ComponentModel;
    using System.Windows.Forms;

    namespace NewLeaseForm
    {
    /// /// Description of LeaseClass.
    ///
    public partial class LeaseClass : Form
    {
    BindingList section=new BindingList();
    BindingList heading=new BindingList();
    BindingSource bSource=new BindingSource();
    public LeaseClass()
    {
    //
    // The InitializeComponent() call is required for Windows Forms designer support.
    //
    InitializeComponent();
    bSource.DataSource=heading;
    lbSection.DataSource=bSource;
    //
    // TODO: Add constructor code after the InitializeComponent() call.
    //
    }
    void BBoldClick(object sender, EventArgs e)
    {
    rtfLeaseText.SelectionFont=new Font(rtfLeaseText.SelectionFont,FontStyle.Bold);
    }
    void BItalicClick(object sender, EventArgs e)
    {
    rtfLeaseText.SelectionFont=new Fo

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups