I am wanting to place a combobox over the Axis title of the bottom axis of a simple 2D, X-Y chart. I can easily create the combobox, but locating the combobox over the bottom axis title location, has proven to be difficult because the Axis.Title member does not seem to update Left and Top properties.
Is there a way I can get access that that information? I have the source code so if needed I could modify our version of the source to meet our needs.
How can I find the location and size of an axis title?
-
- Advanced
- Posts: 192
- Joined: Thu Feb 01, 2007 12:00 am
- Contact:
Hello Mike,
you can know where the bottom axis title is placed using :
you can know where the bottom axis title is placed using :
Code: Select all
private void button1_Click(object sender, EventArgs e)
{
String text = "XXXXXXX";
int twidth = (int) tChart1.Graphics3D.TextWidth(text) / 2;
int xpos = tChart1.Axes.Bottom.IStartPos + (tChart1.Axes.Bottom.IAxisSize / 2) - twidth;
int ypos = tChart1.Axes.Bottom.Position + tChart1.Axes.Bottom.Labels.Height + tChart1.Axes.Bottom.Ticks.Length +
tChart1.Axes.Bottom.AxisPen.Width;
tChart1.Graphics3D.TextOut(xpos, ypos, text);
}
Pep Jorge
http://support.steema.com
http://support.steema.com
-
- Advanced
- Posts: 192
- Joined: Thu Feb 01, 2007 12:00 am
- Contact:
That works!!!
That worked perfectly. Thanks!
-
- Advanced
- Posts: 192
- Joined: Thu Feb 01, 2007 12:00 am
- Contact:
Almost perfect
I have a small problem. When the Chart is resized the position of my combobox is sometimes off and othertimes it is perfect.
i have a method called SetLocation() where I use the code you suggested to set the position of my combobox. I then have tried various events to call the SetLocation method.
I have tried tchart.Layout, tchart.Resize
Both of these events seem to fire inconsistently or the axis label reports bad position values. About half the time the combobox will not move after I have done something to resize the chart.
Is there another event that would work more consistently?
Is it possible to put an event on the Axis label itself ( I could modify my copy of the source to do this)?
i have a method called SetLocation() where I use the code you suggested to set the position of my combobox. I then have tried various events to call the SetLocation method.
I have tried tchart.Layout, tchart.Resize
Both of these events seem to fire inconsistently or the axis label reports bad position values. About half the time the combobox will not move after I have done something to resize the chart.
Is there another event that would work more consistently?
Is it possible to put an event on the Axis label itself ( I could modify my copy of the source to do this)?
Hi Mike,
have you tried to use the OnAfterDraw event ?
About the axis labels, you have the OnGetAxisLabel event which allows to modify the axis labels before to draw, each time that have to be displayed.
have you tried to use the OnAfterDraw event ?
About the axis labels, you have the OnGetAxisLabel event which allows to modify the axis labels before to draw, each time that have to be displayed.
Pep Jorge
http://support.steema.com
http://support.steema.com