0
votes

I create a panel on page left. I added buttons(image-top and text-bottom) on this panel programmatically. Panel's width fixed and when I set the button's height, if text is so long, image and text overlap. But I don't know added button's height.

I add this buttons like

btnFav.Size = new System.Drawing.Size(90, 50);

enter image description here

when I write Autosize show like this,

enter image description here

by the way,

btnFav.ImageAlign = System.Drawing.ContentAlignment.TopCenter;
btnFav.TextAlign = ContentAlignment.BottomCenter;
1
You need to show some code, so that someone can try pointing the problem.Siva Gopal
Insert a TableLayout with two rows inside the panel and place buttons on it.mggSoft
I used but again text and image overlap when I writed autosizeTuba

1 Answers

0
votes

Why not a custom control? Very easy to do, just specify a rectangle where the text needs to be placed, and place the image next to it or ontop or under.

EG.

overriding the onpaint() method

Rectangle textRect = new Rectangle(0, Height / 2, Width, Height / 2);
e.Graphics.DrawString(Text, Font, Brush, textRect, StringAlignment);
e.Graphics.DrawImage(MyImage, 0, 0);

This will place the image above the text, also a much cleaner way of operating