Click here to Skip to main content
11,410,405 members (42,748 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0 C#3.0 C# C#4.0 WinForm
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:

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:

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 14-Jul-12 11:06am
Edited 14-Jul-12 15:10pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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[^]
  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 129
1 Sascha Lefévre 95
2 Maciej Los 68
3 BillWoodruff 60
4 OriginalGriff 60
0 Sergey Alexandrovich Kryukov 8,755
1 OriginalGriff 6,915
2 Maciej Los 3,390
3 Abhinav S 3,248
4 Peter Leow 3,059


Advertise | Privacy | Mobile
Web03 | 2.8.150414.5 | Last Updated 14 Jul 2012
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