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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:35:48+00:00 2026-06-18T11:35:48+00:00

I am very new to C sharp programming. I have the design like as

  • 0

I am very new to C sharp programming. I have the design like as shown below attached image.

My concept is i have to set some volume in “Transfer volume” text box (for example 100) and then press “set” button. It automatically sets the scale of picture box, it is working fine.

Now i want to fill the picture box with colors when i click “Regenerate” button. The percentage of color to be filled in picture box should be the number in the TextBox of that regarding color or liquid.

for example
if i set GasPhase =5 ; Hydrocarbon Liquid =5; Water= 5; Oil Based Mud =5; Water Based Mud =5 ; Not Identified = 75.

then the picture has to fill with 75 % with “Not Identified” color and GasPhase color with 5 % e.t.c.

I have the written some code as shown below.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;


  namespace test
  {
    public partial class Form1 : Form
    {
    public Form1()
    {
        InitializeComponent();
    }

    private void txtTransferVolume_TextChanged(object sender, EventArgs e)
    {

    }

    private void txtTransferSet_Click(object sender, EventArgs e)
    {
        string value = txtTransferVolume.Text;
        double midvalue = Convert.ToDouble(value);
        lblTransferBottleMax.Text = value;
        lblTransferBottleMid.Text = (midvalue / 2).ToString();

    }

    private void chkTransferManual_CheckedChanged(object sender, EventArgs e)
    {


    }

    private void btnTransferBottleRegenerate_Click(object sender, EventArgs e)
    {

    }

   }
 }

Please help me how to fill as i want.

  • 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-06-18T11:35:49+00:00Added an answer on June 18, 2026 at 11:35 am

    This can be achieved quite easily by drawing directly on the picturebox control or creating a bitmap in memory and show in the picturebox.

    Example:

    private void DrawPercentages(int[] percentages, Color[] colorsToUse)
    {
       // Create a Graphics object to draw on the picturebox
       Graphics G = pictureBox1.CreateGraphics();
    
       // Calculate the number of pixels per 1 percent
       float pixelsPerPercent = pictureBox1.Height / 100f;
    
       // Keep track of the height at which to start drawing (starting from the bottom going up)
       int drawHeight = pictureBox1.Height;
    
       // Loop through all percentages and draw a rectangle for each
       for (int i = 0; i < percentages.Length; i++)
       {
           // Create a brush with the current color
           SolidBrush brush = new SolidBrush(colorsToUse[i]);
           // Update the height at which the next rectangle is drawn.
           drawHeight -= (int)(pixelsPerPercent * percentages[i]);
           // Draw a filled rectangle
           G.FillRectangle(brush, 0, drawHeight, pictureBox1.Width, pixelsPerPercent * percentages[i]);
        }    
    }
    

    Of course you have to check that both arrays are the same length, etc. I just want to give you the basic idea of how to do this.

    Here’s a concept of how to get your data in arrays and pass them to the function. Since you are using a different textbox for each value, it’s hard to iterate over them, so right now I’m showing you how to do it using the 6 values you have now.

    private void btnTransferBottleRegenerate_Click(object sender, EventArgs e)
    {
      int[] percentages = new int[6];
      percentages[0] = int.Parse(txtTransferNotIdentified.Text);
      percentages[1] = int.Parse(txtTransferWater.Text);
      // And so on for every textbox
    
      Color[] colors = new Color[6];
      colors[0] = Color.Red;
      colors[1] = Color.Yellow;
      // And so on for every color
    
      // Finally, call the method in my example above
      DrawPercentages(percentages, colors);
    } 
    

    If your percentages don’t always sum to 100, you could use a third parameter that specifies the sum and change the value 100f to this value in the DrawPercentages method.

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

Sidebar

Related Questions

Very new to python and can't understand why this isn't working. I have a
Im very new in C++ I have found this post http://msdn.microsoft.com/en-us/magazine/cc163486.aspx and trying to
I very new to Python, and fairly new to regex. (I have no Perl
I am new to opengl programming, but I am doing something very basic, and
I've been writing C code for quite some time but am very new to
I'm very new to yii, and I'm trying to integrate the facebook-wall-like style into
I have a VPS running a VPS optimized Debian distro. I am very new
I'm brand new to the subject and very lost. I have a text box
Im very new in Qt programming i want to display data with Qt TableView
Am very new on WSDL (SOAP) web service on GAE python, i read some

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.