rckrch
asked on
Size chart control in window of user monitor.
I am trying to write code that will determine the resolution of the screen the user is using in order to properly size charts. I am having trouble getting anything to work. Can someone please help? I am using ASP.Net chart control and vb.net.
Following is code that does not work.
Thanks for the help.
Following is code that does not work.
Thanks for the help.
Dim CurScreenWidth As Integer = Screen.PrimaryScreen.Bounds.Width
Dim CurScreenHeight As Integer = Screen.PrimaryScreen.Bounds.Height
Dim DesignWidth As Integer = 1680
Dim DesignHeight As Integer = 1050
Dim WidthRatio As Single
Dim HeightRatio As Single
WidthRatio = CurScreenWidth / DesignWidth
HeightRatio = CurScreenHeight / DesignHeight
Dim ChartWidth As Single = DesignWidth * WidthRatio * 0.96
Dim ChartHeight As Single = DesignHeight * HeightRatio * 0.85
ASKER
Thanks Kent for the reply. However, the WidthRatio and HeightRatio work fine. I get the appropriate result for the variables. The formula in the code returns the correct numbers, but the chart size is still not adjusted to the screen resolution.
Oh. Ok. :)
What's the context of this code? It looks like the snippet is creating the variables ChartWidth and ChartHeight, and setting them. The values need to be stored in the variables (properties) that are associated with the control.
What's the context of this code? It looks like the snippet is creating the variables ChartWidth and ChartHeight, and setting them. The values need to be stored in the variables (properties) that are associated with the control.
ASKER
This code is in the page load. The chart width property is set in this procedure with Chart1.Width = ChartWidth. Stepping through the procedure I get all of the variables to calculate correctly, but the chart dimensions are much smaller that the screen. This works on my development server, but not on the production server.
I've never experienced this. I've only read of similar behavior reported by others, and it has been reported quite often.
It seems that the cause is almost always a conflict with other installed software. A registry setting, common DLL, or other item that should be benign is causing a different behavior in different environments.
One trick that seems relevant here is to Lock and then UnLock the control. It seems that the control can inherit a Locked status and explicitly locking and unlocking can clear it.
Give that a try.
It seems that the cause is almost always a conflict with other installed software. A registry setting, common DLL, or other item that should be benign is causing a different behavior in different environments.
One trick that seems relevant here is to Lock and then UnLock the control. It seems that the control can inherit a Locked status and explicitly locking and unlocking can clear it.
Give that a try.
ASKER
I don't know what locking and unlocking a control means.
"Locked" is just a property of the form / control.
Chart1.Locked = true;
Chart1.Locked = false;
Try this just before you set the size.
Chart1.Locked = true;
Chart1.Locked = false;
Try this just before you set the size.
ASKER
"Locked" is not among the list of properties on my asp.net chart control.
Apologies. I misunderstood and thought this was a VB object.
Let me do a bit more research. Or maybe one of our other experts can join in.
Let me do a bit more research. Or maybe one of our other experts can join in.
ASKER
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The problem seems to be lines 7 and 8, where you're dividing integers. Convert to the integers to a float or real type and your code should work.
WidthRatio = (single)CurScreenWidth / (single)DesignWidth
HeightRatio = (single)CurScreenHeight / (single)DesignHeight
Good Luck!
Kent