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

  • Home
  • SEARCH
  • 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 480719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:55:17+00:00 2026-05-13T00:55:17+00:00

I am trying to draw a rectangle on a windows mobile phone. Draw the

  • 0

I am trying to draw a rectangle on a windows mobile phone.

  1. Draw the rectangle
  2. Fill the rectangle with a color
  3. Draw it on to the phone.
  4. Give it a event handler that when a user clicks something happens.

I am unsure how do steps 2, 3 and 4. I see that there is a drawing class called rectangle but I don’t know how to get it on the form.

I then don’t know how I could give it a event handler. I am planning to dynamically make like 12 of these so I have to somehow tell which one is clicked and the color it contains in it.

Thanks

Edit so far I have this but I don’t see it on my form.

 Graphics surface = this.CreateGraphics();
    Pen pen = new Pen(Color.Black, 1f);
    System.Drawing.Rectangle test = new Rectangle(0, 0, 500, 500);
    surface.DrawRectangle(pen, test);
  • 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-13T00:55:17+00:00Added an answer on May 13, 2026 at 12:55 am

    It sounds like you want a colored button. I think the easiest way to do this is to inherit from Control and override its Paint event.

    public class ColoredButton : Control {
        protected override void OnPaint(PaintEventArgs e) {
            Graphics graphics = e.Graphics;
            Pen pen = new Pen(Color.Black, 1f);
            SolidBrush brush = new SolidBrush(Color.Red);
    
            graphics.FillRectangle(brush, 0, 0, Width, Height);
            graphics.DrawRectangle(pen, 0, 0, Width-1, Height-1);
        }
    }
    

    Now just hook into the native control Click event.

    Or if you want fancier controls, take a look at this library

    http://code.msdn.microsoft.com/uiframework

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

Sidebar

Related Questions

I'm trying to set up something in SDL [in C++] where I can draw
i am trying to draw a rectangle when i press mouse left button and
I'm trying to create a simple window in Win32 and draw a rectangle in
I'm trying to draw a polygon using c# and directx All I get is
I'm trying to draw a graph on an ASP webpage. I'm hoping an API
Trying to setup an SSH server on Windows Server 2003. What are some good
Trying to find some simple SQL Server PIVOT examples. Most of the examples that
Trying to make a make generic select control that I can dynamically add elements
Looking at a Windows tooltips class hint window, i see that it draws its
I'm trying to create a Win32 window that has rounded corners and is resizable

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.