Custom windows control attachment issue
Let me preface with a Joe Dirt quote... "I'm new, I'm new. And I don't know what to do"
I have a custom user control comprised of 2 picture boxes (one on top of the other) and 3 labels. The top picture box has an image that repeats, and the bottom one has a static image. Think progress bar...
______________________________________________
| PB1 | PB2 |
|----------------------|---------------------|
| Label1 Label2 Label3 |
|____________________________________________|
The top bars length is a function of the users score, from 0 to 100, at 100 the background bar is no longer viable as the top bar fills up the space entirely.
I have a second control attached to my main form that will dynamically create and attach however many of these progress bars to itself as are needed. The control itself has nothing on it, its just a blank user control.
int spacer = (Height - (ProgressBar.Co开发者_如何学运维ntrols_Height * progressBarCount)) / (progressBarCount+ 1);
for (int i = 0; i < progressBarCount.Count; i++)
{
ProgressBar pb = new ProgressBar(progressBarData) { Left = 0 };
if (i == 0)
{
pb.Top = spacer;
}
else
{
pb.Top = (Controls[i - 1].Bottom + spacer);
}
Controls.Add(pb);
_progressBars.Add(pb);
}
The issue is when attaching one of the Progress Bars to the blank user control is that they do not attach to the left of the user control, and the image of only the background picture box gets cut, but the foreground picture box will draw all the way to the max.
-> ______________________________________________
-> | PB1 | PB2 | |
-> |----------------------|------------------|---|
-> | Label1 Label2 Label3 |
-> |_________________________________________|
I have played with every setting in the properties window on both user controls, with similar results. I am at a bit of a loss here and could use some suggestion.
The wrong base image was being used by mistake.
精彩评论