Click here to Skip to main content
15,558,537 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
hey guys,
so I am trying to draw a bunch of squares by using labels,
private void drawSquare()
            List<point> squareMatrix = new List<point>();

            for (int j = 0; j &lt;= 192; j+= 64)
                for (int i = 0; i &lt;= 192; i+=64)
                    squareMatrix.Add(new Point(j, i));

            foreach(Point numb in squareMatrix)
                Label abstractLabel = new Label();
                abstractLabel.Size = new Size(64, 64);
                abstractLabel.BorderStyle = BorderStyle.None;
                abstractLabel.BackColor = Color.Transparent;
                if(numb == squareMatrix[4])
                    abstractLabel.Image = global::strategy_0._2.Properties.Resources.City;
                abstractLabel.Image = global::strategy_0._2.Properties.Resources.Crossroad_plain;
                abstractLabel.Location = numb;

now the problem I run into is that I can't figure out the way how to get rid of the space between labels, when I run it I get small spaces which ruins my idea of having labels connected into a map...
Updated 20-Nov-10 15:28pm
[no name] 20-Nov-10 20:47pm    
Is this web or windows?
Toli Cuturicu 21-Nov-10 9:04am    
Very poor approach. Use labels for what they are intended.

1 solution

Don't use labels, make your own class
Share this answer
xtremas 21-Nov-10 6:17am    
are you saying that it's not possible with label?
Heinzzy 21-Nov-10 14:02pm    
no, but I think that you'll have more control if you implement your own control for this purpose.

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