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 5932163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:47:48+00:00 2026-05-22T14:47:48+00:00

I have a simple bitmap editor for small monochrome bitmaps. And I have a

  • 0

I have a simple bitmap editor for small monochrome bitmaps. And I have a menus which allows to choose thickness of the pen and robber. The problem is that I don’t like the following code. Is there any way to make it more compact?

    private void toolStripMenuItem4_Click(object sender, EventArgs e)
    {
        CurrentPanel.PenThickness = 3;
    }

    private void toolStripMenuItem3_Click(object sender, EventArgs e)
    {
        CurrentPanel.PenThickness = 2;
    }

    private void toolStripMenuItem2_Click(object sender, EventArgs e)
    {
        CurrentPanel.PenThickness = 1;
    }

    private void toolStripMenuItem5_Click(object sender, EventArgs e)
    {
        CurrentPanel.PenThickness = 4;
    }

    private void toolStripMenuItem6_Click(object sender, EventArgs e)
    {
        CurrentPanel.PenThickness = 5;
    }

    private void toolStripMenuItem7_Click(object sender, EventArgs e)
    {
        CurrentPanel.PenThickness = 6;
    }

    private void toolStripMenuItem8_Click(object sender, EventArgs e)
    {
        CurrentPanel.PenThickness = 7;
    }

    private void toolStripMenuItem9_Click(object sender, EventArgs e)
    {
        CurrentPanel.PenThickness = 8;
    }

    private void toolStripButton3_Click_1(object sender, EventArgs e)
    {
        CurrentPanel.EditMode = EditMode.Clear;
    }

    private void toolStripDropDownButton2_Click(object sender, EventArgs e)
    {
        CurrentPanel.EditMode = EditMode.FreeHand;
    }

    private void toolStripSplitButton1_ButtonClick(object sender, EventArgs e)
    {
        CurrentPanel.EditMode = EditMode.Clear;
    }

    private void toolStripMenuItem10_Click(object sender, EventArgs e)
    {
        CurrentPanel.RobberThickness = 1;
    }

    private void toolStripMenuItem11_Click(object sender, EventArgs e)
    {
        CurrentPanel.RobberThickness = 2;
    }

    private void toolStripMenuItem12_Click(object sender, EventArgs e)
    {
        CurrentPanel.RobberThickness = 3;
    }

    private void toolStripMenuItem13_Click(object sender, EventArgs e)
    {
        CurrentPanel.RobberThickness = 4;
    }

    private void toolStripMenuItem14_Click(object sender, EventArgs e)
    {
        CurrentPanel.RobberThickness = 5;
    }

    private void toolStripMenuItem15_Click(object sender, EventArgs e)
    {
        CurrentPanel.RobberThickness = 6;
    }

    private void toolStripMenuItem16_Click(object sender, EventArgs e)
    {
        CurrentPanel.RobberThickness = 7;
    }

    private void toolStripMenuItem17_Click(object sender, EventArgs e)
    {
        CurrentPanel.RobberThickness = 8;
    }

    private void toolStripMenuItem18_Click(object sender, EventArgs e)
    {
        CurrentPanel.RobberThickness = 16;
    }

    private void toolStripMenuItem19_Click(object sender, EventArgs e)
    {
        CurrentPanel.RobberThickness = 32;
    }

    private void toolStripMenuItem21_Click(object sender, EventArgs e)
    {
        CurrentPanel.PenThickness = 32;
    }

    private void toolStripMenuItem20_Click(object sender, EventArgs e)
    {
        CurrentPanel.PenThickness = 16;
    }
  • 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-22T14:47:49+00:00Added an answer on May 22, 2026 at 2:47 pm
    private void toolStripMenuItemCommon_Click(object sender, EventArgs e)
    {
    
         ToolStripMenuItem item = (ToolStripMenuItem) sender;
         int thickness = (int)item.Tag;
    
         CurrentPanel.PenThickness = thickness ;
    }
    

    Of course you need to initialize Tag of each ToolStripMenuItem and set toolStripMenuItemCommon_Click as a handler for Click event. You can do it in a for cycle for example:

    for(int i = 1; i < 8; i++)
    {
        ToolStripMenuItem item = new ToolStripMenuItem();
        item.Text = "Set thickness: " + i;
        item.Click += toolStripMenuItemCommon_Click;
        item.Tag = i;
    
        // add item to strip container
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple method which is called from multiple threads; @Override public Bitmap
I have simple SSIS package which reads data from flat file and insert into
I have simple SSIS package in which On Error event handler I have created
I have simple WinForms application where modifying Windows Registry. The problem is that in
I have a simple one channel (8bit) bitmap with luminance data only , and
i have simple url of image, i want to display that image in Bitmap
I have a simple page with a panorama and a button which have to
I have a Windows C++ program which receives and saves bitmap files (*.bmp). My
How to copy something as a pastable bitmap in flash? So I have simple
I have a movie clip that holds one bitmap image, some simple AS3 to

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.