Click here to Skip to main content
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 Kornfeld Eliyahu Peter 169
1 George Jonsson 145
2 Zoltán Zörgő 139
3 PIEBALDconsult 130
4 OriginalGriff 120
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,382


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