Click here to Skip to main content
15,891,993 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
Hey there,

I was originally trying to add a background image to a Richtextbox when I quickly found out it could not be simply achieved. I kept reading on online and stumbled upon someone who said something about creating a new usercontrol adding a richtextbox and then implementing this code to work with a textbox rather than a label:

C#
public class TransparentLabel : Label {
  public TransparentLabel() {
    this.SetStyle(ControlStyles.Opaque, true);
    this.SetStyle(ControlStyles.OptimizedDoubleBuffer, false);
  }
  protected override CreateParams CreateParams {
    get {
      CreateParams parms = base.CreateParams;
      parms.ExStyle |= 0x20;  // Turn on WS_EX_TRANSPARENT
      return parms;
    }
  }
}


So I tried:

C#
public class UserControl1 : RichTextbox
    {
        public UserControl1()
        {
            this.SetStyle(ControlStyles.Opaque, true);
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, false);
        }
        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams parms = base.CreateParams;
                parms.ExStyle |= 0x20;
                return parms;
            }
        }
    }


But I end up with the following error and I am unsure how to fix it:
Error 1 Missing partial modifier on declaration of type 'Stickies.UserControl1'; another partial declaration of this type exists

This error is on the following line:
public class UserControl1 : RichTextbox

Any help with my error or any help on another approach would be really helpful.
Thank you.
Posted
Updated 14-Jul-12 14:10pm
v2
Comments
Liran Friedman 17-Oct-17 5:32am    
How did you solve the issue with text being smeared when scrolling?

1 solution

From the error message I would think you have another class file in your project declared as "partial class UserControl1" if this is intentional all parts of the UserControl1 must be declared as "partial".

http://msdn.microsoft.com/en-us/library/wa80x488(v=vs.80).aspx[^]
 
Share this answer
 
Comments
Liran Friedman 17-Oct-17 5:33am    
How would you solve an issue with text being smeared when scrolling?

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900