how to draw a string in the center of a control?

B

Bonna

Hi,

Some controls I use receive databasedata like a TreeView, ListView, Grid...
I'd like to display a cool centered "No data available." string when no data
is retrieved.

Is there a way to draw a text in the center of these controls?

I've got it thusfar:
- I'm using the top and left props of the control to get the rectangle to
draw in.
eg.: with e.Graphics.DrawString(....)
- I can position this text centered.

What I cannot do is draw the string after the form draws it's child
controls...
The control is always rendered over my text.

Can someone explain how to do this?

deepest regards,

Bonna
 
H

Herfried K. Wagner [MVP]

* "Bonna said:
Some controls I use receive databasedata like a TreeView, ListView, Grid...
I'd like to display a cool centered "No data available." string when no data
is retrieved.

Is there a way to draw a text in the center of these controls?

I've got it thusfar:
- I'm using the top and left props of the control to get the rectangle to
draw in.
eg.: with e.Graphics.DrawString(....)
- I can position this text centered.

What I cannot do is draw the string after the form draws it's child
controls...
The control is always rendered over my text.

You may want to override the control's 'OnPaint' method, but I doubt
that this will work. Why not place a label above the control?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top