I woud like to scroll UltraChart horizontally by mouse wheel with Shift key pressed. How can I do that?
The problem is solved. I don't know how, but it works), probably there are parent control scrollbars:
private void KSMap_MouseWheel(object sender, MouseEventArgs e){ HandledMouseEventArgs he = e as HandledMouseEventArgs; if (he == null) return; if (ModifierKeys == Keys.Control) { // Zoom if (e.Delta > 0) { ZoomIn(); } else if (e.Delta < 0) { ZoomOut(); } he.Handled = true; } else if (ModifierKeys == Keys.Shift) { // Horizontal scroll if (Parent != null && Parent is ScrollableControl) { ScrollableControl parent = Parent as ScrollableControl; parent.AutoScrollPosition = new Point(-parent.AutoScrollPosition.X - e.Delta, parent.AutoScrollPosition.Y); } he.Handled = true; }}
Thanks anyway for your attention!
Can you attach a complete zipped up project? It's not clear from your code what you're doing and how this Size property is affecting the chart. If you're using it to change the size of the actual chart, then it will have no effect on the chart's scrollbars. All of chart's primitives will just get scaled according to the new size.
The scale of the chart is changed at the event time, horizontal scrollbar is visible and there is the space to scroll. However, nothing happens. By the way, your code has no effect too. I use the following code to change the scale:
public void ZoomIn(){ Size newSize = Size; Dock = DockStyle.None; newSize.Height = (newSize.Height > 2000) ? newSize.Height : newSize.Height + 100; newSize.Width = (newSize.Width > 2000) ? newSize.Width : newSize.Width + 100; Size = newSize;}
public void ZoomOut(){ Size newSize = Size; Dock = DockStyle.None; newSize.Height = (newSize.Height < 150) ? newSize.Height : newSize.Height - 100; newSize.Width = (newSize.Width < 150) ? newSize.Width : newSize.Width - 100; Size = newSize;}
private void KSMap_MouseWheel(object sender, MouseEventArgs e){ HandledMouseEventArgs he = e as HandledMouseEventArgs; if (he == null) return; if (ModifierKeys == Keys.Control) { // Zoom if (e.Delta > 0) { ZoomIn(); } else if (e.Delta < 0) { ZoomOut(); } he.Handled = true; } ...}
I think what you actually want to do is change the scale of the chart, instead of the scroll. Scrolling is just moving the chart horizontally in your case, but since the chart starts out fully zoomed out, there's nowhere to scroll. Try this instead:HandledMouseEventArgs he = e as HandledMouseEventArgs;if (he == null) return;if (ModifierKeys == Keys.Shift){ if (ultraChart1.Axis.X.ScrollScale.Visible) { double newScale = ultraChart1.Axis.X.ScrollScale.Scale; if (e.Delta > 0) { newScale -= 0.1; if (newScale > 1) newScale = 1; } else if (e.Delta < 0) { newScale += 0.1; if (newScale < 0) newScale = 0; } ultraChart1.Axis.X.ScrollScale.Scale = newScale; } he.Handled = true;
I tried to use this mouse wheel event handler:
private void MapChart_MouseWheel(object sender, MouseEventArgs e){ HandledMouseEventArgs he = e as HandledMouseEventArgs; if (he == null) return; if (ModifierKeys == Keys.Shift) { if (Axis.X.ScrollScale.Visible) { double newScroll = Axis.X.ScrollScale.Scroll; if (e.Delta > 0) { newScroll += 0.1; if (newScroll > 1) newScroll = 1; } else if (e.Delta < 0) { newScroll -= 0.1; if (newScroll < 0) newScroll = 0; } Axis.X.ScrollScale.Scroll = newScroll; } he.Handled = true; }}
but it doesn't work. What's wrong? By the way, the version is 9.2.20092.2035