Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3974622
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:35:21+00:00 2026-05-20T04:35:21+00:00

I am having a go at creating some custom controls based on specific configurations

  • 0

I am having a go at creating some custom controls based on specific configurations that I use.

My first one, is simply to create a standard exit button. However, it’s not working how I think. Essentially, I want the default text to be “Exit Application”, when it is added to the form. Unfortunately, the two ways that I have thought of, dont actually show that, instead it shows the name of the button class, i.e. “CustomExitButton1”. This is the two ways I have tried:

public class StandardExitButton : Button
{

    public StandardExitButton()
    {
        this.ControlAdded += new ControlEventHandler(StandardExitButton_ControlAdded);
    }

    void StandardExitButton_ControlAdded(object sender, ControlEventArgs e)
    {
        Text = "Exit Application";
    }
}

And:

public class StandardExitButton : Button
{

    public StandardExitButton()
    {
        this.Text = "Exit Application";
    }


}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T04:35:22+00:00Added an answer on May 20, 2026 at 4:35 am

    I’ve done this with a bunch of buttons, such as Add, Edit, Delete, Cancel, Ok, Exit, etc… In addition to keeping all my buttons, labels, textboxes, etc with my own standard font sizes, colors, etc … For the text, on each subclassed button, I did something like …

    [ReadOnly(true)]
    public override string Text
    { get { return "&Exit Application"; } }
    

    Never have to worry about a “setter” since the button’s text should never change in the designer or derived…

    EDIT — more complete sample…

    public class MyButton : Button
    {
        [ReadOnly(true)]
        public sealed override Font Font
        { get { return new Font("Arial", 9F, FontStyle.Italic, GraphicsUnit.Point); } }
    
        [ReadOnly(true)]
        public sealed override Color ForeColor
        { get { return Color.Blue; } }
    
        public GDITButton()
        { }
    }
    
    
    public class MyExitButton : MyButton
    {
        [ReadOnly(true)]
        public override string Text
        { get { return "Exit"; } }
    
        public MyExitButton()
        {}
    }
    
    public class MyAddButton : MyButton
    {
        [ReadOnly(true)]
        public override string Text
        { get { return "Add"; } }
    
        public MyAddButton()
        {}
    }
    

    Then, when you put an instance of the MyExitButton or MyAddButton on the form, it will FORCE the caption for you and also prevent you from changing it as it is a read-only property of the respective class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im having some problems creating a custom search form for jqGrid, on the last
I'm having some trouble setting up my custom header in my list. I'm creating
I am having some problems creating custom types for my data table, using jquery.datatables.js.
I'm having some issues with producing an int matrix without creating memory leaks. I
I'm having trouble creating a mouseover function with an NSTableView. The idea is that
I have been creating Unit tests like crazy and find that I'm often having
Having a object x which is an instance of some class how to create
Morning, I'm having some trouble creating tables/loading fixtures. (symfony 1.4.6 with the bundled Doctrine
I'm relatively new at creating custom content for Sharepoint 2010 and have been having
I am having some trouble pulling multiple custom post types from a Custom Wordpress

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.