Click here to Skip to main content
15,907,328 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in my project i have to when i click on the star show the name of the star. the solution is to draw the star on the PictureBox and them draw this PictureBox .and when i click in the star i click in the PictureBox(object) and show the name.
N.B: i have to draw more than 1000 star. for each star i want to show the name.
Posted
Updated 8-Feb-17 8:57am
Comments
CHill60 11-Jan-14 11:43am    
This doesn't make a lot of sense. What have you tried and what is the problem?

Drawing a filled circle is easy: just get the Image control from your picturebox and use the FillEllipse method:
C#
Image i = myPictureBox.Image;
using (Graphics g = Graphics.FromImage(i))
    {
    g.FillEllipse(Brushes.White, new Rectangle(100, 100, 10, 10));
    }

When you have drawn them, just call myPictureBox.Invalidate() to display them all.
If I was you, I'd create a Star class which included it's name, location, and (display) size, so you could then look for it when you clicked on the picturebox.
 
Share this answer
 
Comments
Bakhos Sayssouk 11-Jan-14 14:49pm    
noo. in one step(in boocle for),i want to create a PictureBox(picturebox[] p=new picturebox[i]).and to draw at the picturebox a circle,tham to set the picture.
OriginalGriff 12-Jan-14 4:25am    
You do not want to do that: one PictureBox per star?
That's like drawing a house by painting each brick on a separate piece of paper, then glueing them all together...
Do you have any idea how many window handles that will use up? :OMG:
Bakhos Sayssouk 11-Jan-14 15:17pm    
or i can draw a circle fill object wen i click to the circle(star) show the star name ??? thank you in advance.
OriginalGriff 12-Jan-14 4:28am    
Depends - if you use one picture box, and keep each star separate (and holding a rectangle describing it's size and position relative to the TLHC of the image as well as it's name) then it's a fairly simple operation to find out which star's rectangle you clicked in from the PictureBox.Click event handler. Then all you have to do is show the name from the star class info.
Bakhos Sayssouk 12-Jan-14 10:26am    
yes one PictureBox per star.i have a name of the star on xml.
or Graphics g = pictureBox1.CreateGraphics();
etc
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900