How to disable zoom in chart control in C#? - c#

How can i disable zoom after mouse selection in System.Windows.Forms.DataVisualization.Charting.Chart control in a .Net 4.0 WinForms application? Actually I want to use selected area in other case but not for zooming.

Just set:
chart.ChartAreas["ChartAreaName"].AxisX.ScaleView.Zoomable = false;
chart.ChartAreas["ChartAreaName"].AxisY.ScaleView.Zoomable = false;

I have the same problem,this helpfull for me.
chart1.ChartAreas[0].AxisX.ScaleView.Zoomable = false;
chart1.ChartAreas[0].AxisY.ScaleView.Zoomable = false;

Related

How to reproduce a forum/twitter-like UI on Winform

As a classic forum, threads and replys are displayed on a page, with dark and light and dark and light backcolor.
I am trying to write a client of a forum on windows using winform. It is
At first, I have tried this way:
Add a big panel to the form, let's call it the PARENT PANEL.
Add small panels to the big panel like this:
panel1.Visible = false;
for (int i=0; i<5;i++)
{
Panel parent = new Panel();
parent.Height = 800;
Random ra = new Random();
TextBox p = new TextBox();
p.Text = "fehsuifq";
p.Multiline = true;
p.WordWrap = true;
p.Dock = DockStyle.Fill;
parent.BackColor = Color.FromArgb(ra.Next(0, 254), ra.Next(0, 254), ra.Next(0, 254));
p.BorderStyle = BorderStyle.None;
p.ReadOnly = true;
p.TabStop = false;
p.BackColor = this.BackColor;
parent.Controls.Add(p);
parent.Dock = DockStyle.Top;
panel1.Controls.Add(parent);
}
panel1.Visible = true;
Every panel(tenicially, a control) displays a thread's text and images and others details(like authors or avator).
Images are not shown until it is clicked.
when the image is clicked, it is loaded and the controls's height will change as result.
The PARENT PANEL will contains hundreds of these controls since there will be so many threads. It is and have to be scrollable, obviously.
But if I put a textbox in the control, the scroll wheel no longer work on the PARENT PANEL.If I use a label, it is not selectable.
I think this way can't be more stupid, completely.
So I am looking for a better to do this job, to display hundreds or even thousands threads/replys on winform, which is:
the height is dynamic, because the images inside will not load until it is clicked.
The text inside is selectable (I edited this just to disambiguate)
the PARENT PANEL can response to the mouse's wheel, just like twitter, forums.
So that I can use my scroll wheel to browse all the replys at one time. The loading is a background work.
Look at the picture, when the text is selected, the whole panel is still response to the wheel(just like normal webPage). This is a uwp app and I am not sure if winform can do this.

FlowLayoutPanel AutoSize only in vertical?

I'm loading images dynamically inside a FlowLayoutPanel. I need for this panel to auto-size but only vertically.
Is this possible, and if so, how do I go about achieving it?
Simple, add a event of type control added:
private void flowLayoutPanel1_ControlAdded(object sender, ControlEventArgs e)
{
if (flowLayoutPanel1.Controls.Count % 10 == 0)
flowLayoutPanel1.SetFlowBreak(e.Control as Control, true);
}
set AutoSize = true
set flowdirection = LeftToRight
Maybe
FlowLayoutPanel1.WrapContents = False;
FlowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
will help you.
I did set the Size from panel dinamically. Example:
int newHeight= listImages.Count/10 * 100;
flowLayoutPanel1.Size = new Size(1143, newHeight);
It works for me. Thx all
This might look like an ugly solution, but it works for me:
Store current width of a panel in variable;
Set AutoSize mode to true;
Perform the action that require panel resize;
Restore previous panel's width from the variable.
int i = _panel1.Width;
_panel1.AutoSize = true;
_panel1.AutoSizeMode = AutoSizeMode.GrowOnly;
/*some action going on here*/
_panel1.AutoSize = false;
_panel1.Size = new Size(_panel1.Width, 80);

Creating Settings form using TreeView in C#

I am developing the settings form for the software developed in C#. I was looking at how different software have implemented their settings form.
In most of the cases that I came across, they seem to be using Treeview on the left pane of the form and configuration settings on the right pane.
Ref URL : http://2.bp.blogspot.com/-nMfQoLurxwM/UDXfiZKd4DI/AAAAAAAAAME/IRf6kmxay4w/s1600/bild1.jpg
I was wondering, how the different controls are designed/displayed on the right pane. Do they hide all the controls depending which node is selected in the TreeView something like this :
if (treeView1.SelectedNode == treeView1.Nodes[0])
{
this.groupBox1.Visible = true;
this.button1.Visible = true;
this.textBox1.Visible = true;
this.textBox2.Visible = true;
this.label1.Visible = true;
this.label2.Visible = true;
this.label3.Visible = true;
}
else
{
this.groupBox1.Visible = false;
this.button1.Visible = false;
this.textBox1.Visible = false;
this.textBox2.Visible = false;
this.label1.Visible = false;
this.label2.Visible = false;
this.label3.Visible = false;
this.groupBox2.Visible = true;
this.button2.Visible = true;
this.textBox3.Visible = true;
this.textBox3.Visible = true;
this.labe4.Visible = true;
this.label5.Visible = true;
this.label6.Visible = true;
// bool success = selectColor();
}
Is my understanding correct ? Or do we have a better design approach for creating a settings form.
Thanks
You can create panels and swap their visibility. So depending on what setting is selected, you fill the controls and display a particular panel.
There are many ways but you can have a combination of Treeview control and Tab control. Check this link. This may help. In this link, the tabpages of tabcontrol are used as treeview control nodes.
Have a look at this link too.

Troubles with setting ToolTip duration programmatically

I've come across a situtation where I need to create a tooltip object and show it when the user hovers over specific areas in my application.
I can get the tooltip to show up just fine. The problem is I need it to go poof after a few seconds have passed. I'm aware of the ToolTipService.SetShowDuration and I've tried using it, but I have not been met with much luck.
Here's what I got in my MouseMove event handler:
_toolTip.Placement = PlacementMode.Relative;
_toolTip.Horizontal = e.X;
_toolTip.VerticalOffset = e.Y;
_toolTip.Content = stuffs;
_toolTip.IsOpen = true;
I've tried setting the following:
someObject.ToolTip = _toolTip;
ToolTipService.SetShowDuration(someObject, 5);
Nothing changes with the last two lines. The tooltip still is visible and stays visible. Am I using the service wrong or something? Any thoughts would be much appreciated!
Try this.
<Border Name="border" ToolTip="some message" MouseEnter="border_MouseEnter" Background="red" Margin="50"/>
ToolTip tool = new ToolTip();
private void border_MouseEnter(object sender, MouseEventArgs e)
{
tool.Placement = PlacementMode.Relative;
tool.HorizontalOffset = 100;
tool.VerticalOffset = 200;
tool.Content = "stuffs";
tool.IsOpen = true;
border.ToolTip = tool;
ToolTipService.SetShowDuration(border, 5000);
}
I developed a workaround for the issue.
To give a little more background, I have a 3D model of an aircraft inside of a WindowsFormsHost object. When the user hovers over a identified part, I needed a tooltip to appear.
I created an instance of tooltip and in my MouseMove event and I do something like this:
// selectedPart will be null if no part is selected
if(selectedPart != null && prevSelectedPart != selectedPart)
{
toolTip.IsOpen = false;
host.ToolTip = toolTip;
toolTip.IsOpen = true;
}
else if (prevSelectedPart == selectedPart && prevSelectedPart != null)
{
toolTip.IsOpen = true;
}
else
toolTip.IsOpen = false;
That does the trick for me.

Implementing a tooltip on a trackbar in c#

I am trying to implement a trackbar with a tooltip. What I want is that the tooltip to appear at certain values when the trackbar is scrolling and then disappear ( and appear at the x,y coordinate of that value).
I have been able to get the tooltip up and running but unfortunately it appears all the time when the mouse hovers over the trackbar.
Using .NET framework 2.0
Any help/suggestions greatly appreciated.
Thanks
You need this overload of Tooltip.Show
I think you should use a balloon tooltip
ToolTip btt= new ToolTip();
btt.ToolTipTitle = "Tooltip";
btt.UseFading = true;
btt.UseAnimation = true;
btt.IsBalloon = true;
btt.ShowAlways = true;
btt.AutoPopDelay = 5000;
btt.InitialDelay = 1000;
btt.ReshowDelay = 500;
btt.SetToolTip(button3, "Clicked.");

Categories

Resources