Click here to Skip to main content
13,045,379 members (123,618 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi everyone,

I am creating GUI using c# windows application program. I am quite new to this programming. I am trying to fill pictureBox with different colors based on some conditions.

I am trying to estimate the incoming quantity which is coming from the system. Initially I will set the expected volume of quantity is going to come(ucSample.Volume)from system, this will assign as a scale to pictureBox. This is working perfectly. I have certain conditions for estimating incoming quantity. I have one volume sensor which is going to give how much quantity already came from system(stored in variable "volume"). I am updating picture box every second. I have assigned color for each quantity.

for example: I have set estimated volume to "500"(ucSample.Volume=500), then i will start the system. System will pour the liquid slowly, it will take 30 mints for 100ml quantity to pour. When system pass liquid slowly at that time i will read the density, pressure, temperature of that liquid using sensors and checking which condition is met, according condition it will select one color. So i have one volume sensor which gives reading of volume which passed through system up to now. It will update every second, for example up to now the system passes only 10 ml liquid. So picture box has to update only up to 10 in the scale(scale of 500) with regarding color. Next suppose from 10 ml to 20 ml the incoming liquid changed so conditions will be different so now i need to fill pictureBox with different color from 10 ml to 20 ml scale. (not from 0 to 20ml), this should be like this, it won't need to change the color of previous one which is from "0 to 10 ml" keeping the same color and add different color from "10 to 20 ml". So the concept is i need to keep the previous one as it is and keep updating from the previous end point. i am updating every second.
So we don't know what is coming from system so finally after seeing pictureBox we have to estimate how much quantity (total) came from system and as well as individual quantity of each type. it is updating like first it will fill with "green" color from "0 to 100ml" and if quantity changed from 100 to 200 then it is filling with another color from "0 to 200 ml". (not from "100 to 200".) I am losing the previous information so it is totally wrong. I need to keep the initial color as it is up to how much it has already drawn before any changes in liquid then if any changes come it has to start from that point.

I hope i have given more clear explanation. Please help me if any one understand my concept.
Posted 13-Mar-13 4:29am
Updated 20-Mar-13 5:50am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

First of all, you should not use PictureBox at all. This is a middleman which is only useful in the simplest cases, but it only adds some hassles, eats up your development time and some extra system resources not giving anything in return. I'll tell you what you should be doing instead. Please see my past answers:
How do I clear a panel from old drawing[^],
draw a rectangle in C#[^],
Append a picture within picturebox[^].

And then, you should understand how rendering really works. Please see my past answers:
Drawing Lines between mdi child forms[^],
capture the drawing on a panel[^],
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^],
How to speed up my application?[^].

Just start from there and you will see how to do things properly.


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 20 Mar 2013
Copyright © CodeProject, 1999-2017
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