I have a program with a large c# chart control. I am allowing zooming by allowing the user to select any area and it will zoom in. This all works fine. When I go to scroll horizontally this also works fine and very smooth. However when I try to scroll vertically the scroll bar wont move, the only thing I can do is use the up and down arrow keys on the scroll bar and that only gives either the very top of the graph or the very bottom of the graph I can't scroll to anything in between. Any ideas on what could be happening? Please let me know what additional information I can provide.
thanks!
Some of my properties:
ChartArea
CursorX & CursorY
AutoScroll = True
AxisType = Primary
IsUserEnabled = True
IsUserSelection = True
I have found the solution to my problem.
I needed to lower the value under
chartAreas.AxisY.ScaleView.SmallScrollMinSize
the values on my Y axis where much smaller then the ones on my X axis thus I had to have a smaller "SmallScrollMinSize" in order for scrolling to work appropriately.
I figured this out from this article
http://www.codeease.com/scrolling-stuck-in-microsoft-chart-control-2.html
Related
I asked this over at StackOverflow and someone suggested I try here, so...This program uses winforms and c# (no wpf). I have a panel with buttons on it and getting it to scroll is no problem. However, when the program is on a hi-resolution touch screen -- like a Surface 7 -- trying to touch in the exact right spot to get it to scroll is hit and miss. I've searched and have yet to find a way to make the grab area (so to speak) of a vertical scroll bar wider so that when you touch the screen, the control actually picks up the event. Any ideas on how to do this?
This can be a super user question if youre looking for a tool to make it wider for all apps because it could be considered as an accessibility.
If you're writing an app
Vertical Scroll Bar Width
System.Windows.Forms.SystemInformation.VerticalScrollBarWidth;
Horizontal Scroll Bar Width
System.Windows.Forms.SystemInformation.HorizontalScrollBarHeight;
Duplicate of
Change width of scrollbars
I'm currently working with a DevExpress ChartControl with several panes stacked vertically on top of each other. The panes can individually be shown or hidden at runtime, but their contents won't change after they're created. I'd like to remove all space between the panes so that the border of each is totally flush with the border of the pane above/below it.
I've already used the following code to set the PaneDistance to 0, which normally would do exactly what I'm looking for:
XYDiagram diagram = chartControl1.Diagram as XYDiagram;
diagram.PaneDistance = 0;
However, the problem I'm running into, visible in the screenshow below, is that the labels on my y axes can sometimes extend vertically above or below the edge of the pane itself, which forces there to be space between my panes.
The first two panes have no space between them at all, which is exactly what I want, but the problem can be seen on the bottom whree panes. The "0" label on the second pane extends slightly below the table, so empty space is added to allow it to fit. The bottom two axes both have labels that extend outside their panes, so even more space is being added.
I've tried editing every property of these axes that I can think of, but nothing has been able to remove this blank space. It seems like just getting the outer labels to be pushed up or down so they're inside the pane height should do the trick. Anyone have any ideas on how I can get this working like it should?
Edit: I'll mention that in a different part of this app, I have a different set of panels, rotated and aligned horizontally, with their axis labels doing what I want them to do in the case above:
You can see that the "0" and "300" labels are shifted slightly off-center to fit within their own pane, so they don't extend out and create empty space. I didn't have to touch any code to get that to happen. It could be because these are all instances of the same axis, while the ones that don't do this are different axes, that causes them to play nice in this case?
Edit 2:
Here's what I've got after setting my axis SideMarginsValues to 0 and AlwaysShowZeroLevel to false. Getting closer!
if you can't achieve what you need with DX chart's public properties there is still one trick you can try.
In Browser choose Inspect the chart area (CTRL+SHIFT+I in Chrome) and find the actual chart's element or the parent element and see what classes/ids DX have assigned to them.
Then pick the nearest element class/id and try to play with it's css by assigning negative margins/paddings like:
.dxtcLite.dxtc-top .dxtc-stripContainer {
margin-botton: -2px!important;
}
This is of course a dirty solution but sometimes it's the only one which works.
However, if you don't have any HTML-type margin/padding between chart panes but the blank space is actually a part of the generated chart Image, then probably the only thing you can do is to continue playing with DX chart properties which affect the actual chart image generation.
UPDATE:
Have you tried setting the Range.SideMarginsValue property to 0?
diagram.AxisY.WholeRange.SideMarginsValue = 0;
Another option would be to try to always hide 0-level axis label using
WholeRange.AlwaysShowZeroLevel :
diagram.AxisY.WholeRange.AlwaysShowZeroLevel = false;
or try setting max values for the axis values to exclude border labels:
// depending on possible min/max values for each pane
diagram.AxisY.WholeRange.SetMinMaxValues(5, 35 );
Let me know if anything of the above helps.
I am not sure if it is a duplicate question but I could not find any answer on StackOverflow.
Problem Statement: I have Third party Image Viewer and PDF viewer controls. which are embedded into C# WinForms page. I want to control scrollbars movement in percentage. For example, if I press "down" key then vertical scroll bar should move down to 20% of page height. I have tried with below logic:
_imageViewer.VerticalScrollBar.Value += _imageHeight X ZoomFactor X .20
OR
_imageViewer.VerticalScrollBar.Value += pdfViewer1.VerticalScroll.Maximum X .20
Both approaches are not giving me the exact result. I think I should also consider thumb size of scroll bar but I don't know how can I get that value.
Please suggest me any good approach to moving scrollbar in the percentage of image height or width.
You can assign SmallChange property of ScrollBar to suitable value. As mentioned in documentations, When the user presses one of the arrow keys or clicks one of the scroll bar buttons, the Value property changes according to the value set in the SmallChange property.
Example:
vScrollBar1.SmallChange = ((vScrollBar1.Maximum - vScrollBar1.Minimum) * 20 / 100);
C# WinForms: if I want to have the location of a control on a panel regardless of where is the Vertical scroll bar, what should I use? I mean the form is large so we use scroll bar to move up and down, now I want that location to be independent of where I have set the scroll bar this.PointToClinet?
The Location property is already independent of the scrollbar position. A control at (0,0) stays at (0,0) in a panel with a scrollbar. What changes is the AutoScrollPosition property value. With a vertical scrollbar, the AutoScrollPosition.Y value becomes negative when the user scrolls down. Which makes whatever is inside the panel move up.
Trying to keep something in the same position even if the scrollbar is used is technically possible by correcting for AutoScrollPosition.Y. But doesn't work well in practice, whatever you are scrolling is doing the pogo, rapidly jumping up and down as you scroll. Which is caused by Windows blitting the scrolled pixels after which you redraw it back in the original position. Find a workaround for that problem in this post.
I have a tabcontrol with several tabpages. I also have hooked into the InputPanel.EnabledChanged event so that the tabcontrol resizes when the inputpanel is enabled. What I would like to do is ensure that the control with the focus is visible when the tabpage is resized. What's the best way to accomplish this. Note that I am using the .NET Compact Framework.
Thanks,
MrB
You have a couple of things you need to/may want to keep track of here:
• Current scroll position
• Position of the tapped element (I assume a textbox) when they tapped it
Note that the EnabledChanged event for the InputPanel is pretty easy to deal with (I assume you've already done it): check the InputPanel's Enabled state and do a += or -= to the tabcontrol's Height so the InputPanel doesn't cover anything up.
My understanding is that your issue is really to determine where the textbox was, because your worst-case scenario is that it will be moved off-screen when the tabcontrol resizes.
I believe (not 100% certain) that resizing a tabcontrol will keep the top of the tabcontrol contents visible and you'll have to scroll down to see anything that is now "covered" by the InputPanel.
What you'll want to do in the EnabledChanged event is find out the location of the control that was tapped (or the screen coordinate that was tapped - whatever is easiest for you). If it falls within the danger zone of (ClientSize.Height-InputPanel.Bounds.Height,ClientSize.Height), you'll need to adjust your scroll.
This is half-C#-half-pseudocode but you should be able to see where I'm going with it:
int yOffset = top y-coordinate of the tapped control;
if ( yOffset > ClientSize.Height-inputPanel.Bounds.Height )
{
int yShift = amount to shift everything up;
Point scrollPosition = AutoScrollPosition;
scrollPosition.Y = scrollPosition.Y - yShift;
AutoScrollPosition = scrollPosition;
}
What this does, in a nutshell, is checks if your InputPanel is going to cover up the desired control, and if so, scroll up by yShift pixels, where yShift might be the whole height of the inputPanel, or just enough to barely show your control (whatever you want).
• .NET CF seems very forgiving about setting invalid scroll rules. If you can only scroll up 10 pixels and you tell it to scroll up 100, it will stop at 10.
• Screen coordinate (0,0) is the top left of the visible screen - NOT the form being displayed. You can get tripped up if you assume that (0,0) is the top of your form.
The only way that comes to my mind is calculate this by currrent controls positions on a screen.