Hi I have a windows form in my application with a tab control inside it. I have noticed that when I restore the application from the taskbar after minimizing it, the tabpage shrinks to half it's normal size and all controls inside move downwards. I have the tabpage docked to fill inside a TablePanelLayout. The tabs stay in place though. This does not happen upon resizing the form. Please help.
This is the relevant code from the designer.cs file
//
// tabControl1
//
this.tabControl1.Appearance = System.Windows.Forms.TabAppearance.FlatButtons;
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Controls.Add(this.tabPage3);
this.tabControl1.Controls.Add(this.lookupTab);
this.tabControl1.Controls.Add(this.tabPage4);
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl1.ItemSize = new System.Drawing.Size(71, 35);
this.tabControl1.Location = new System.Drawing.Point(3, 110);
this.tabControl1.Multiline = true;
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(1453, 601);
this.tabControl1.TabIndex = 0;
this.tabControl1.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged);
//
// tabPage1
//
this.tabPage1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.tabPage1.Controls.Add(this.panel2);
this.tabPage1.Location = new System.Drawing.Point(4, 39);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.tabPage1.Size = new System.Drawing.Size(1445, 558);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "Settings";
this.tabPage1.UseVisualStyleBackColor = true;
//
// tabPage2
//
this.tabPage2.Controls.Add(this.label5);
this.tabPage2.Controls.Add(this.label4);
this.tabPage2.Controls.Add(this.label2);
this.tabPage2.Location = new System.Drawing.Point(4, 39);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(1445, 558);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "Calibration";
this.tabPage2.UseVisualStyleBackColor = true;
I found what was wrong. Posting it here in case someone else has the same problem.
I set this.tabControl1.Multiline = true; to false and the problem disappeared.
Related
I have a list of items that is constantly updated from live readings, the newest items should be added on the top of the list.
is it possible to have an item template for the list view with 2 rows and 2 column for each item. (like attached photo).
I searched online i could not find a solution.
my second approach was to create Main Panel and append Panels to it sub panels to it containing the labels.I am only able to add the items in the bottom of the Main panel since i can calculate the location of the last added item.
Panel pan = new Panel();
pan.Name = "panel" + counter;
pan.BorderStyle = BorderStyle.FixedSingle;
Label label1 = new Label();
label1.AutoSize = true;
label1.Location = new System.Drawing.Point(0, 0);
label1.Name = "label" + counter;
label1.Size = new System.Drawing.Size(35, 13);
label1.TabIndex = 1;
label1.Text = "label" + counter;
Label label2 = new Label();
label2.AutoSize = true;
label2.Location = new System.Drawing.Point(0, 20);
label2.Name = "label2" + counter;
label2.Size = new System.Drawing.Size(35, 13);
label2.TabIndex = 2;
label2.Text = "label2" + counter;
Label label3 = new Label();
label3.AutoSize = true;
label3.Location = new System.Drawing.Point(40, 0);
label3.Name = "label3" + counter;
label3.Size = new System.Drawing.Size(35, 13);
label3.TabIndex = 3;
label3.Text = "label3" + counter;
Label label4 = new Label();
label4.AutoSize = true;
label4.Location = new System.Drawing.Point(40, 20);
label4.Name = "label4" + counter; ;
label4.Size = new System.Drawing.Size(35, 13);
label4.TabIndex = 4;
label4.Text = "label4" + counter;
pan.Location = new Point(0, counter * 50);
pan.Size = new Size(100, 50);
pan.Controls.Add(label1);
pan.Controls.Add(label2);
pan.Controls.Add(label3);
pan.Controls.Add(label4);
MainPanel.Controls.Add(pan);
counter++;
Thanks
I'm using LiveCharts in WinForms. Reason why I'm not using WPF is because I don't want to rewrite the GUI in WPF, so I'm trying to see if I can make LiveCharts work in WinForms.
I'm saving the LiveCharts control as an image to a PDF, so the title needs to be on the chart itself.
I cannot find any functionality for adding a title on the chart. What I have tried is the following:
VisualElement title = new VisualElement();
title.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
title.VerticalAlignment = System.Windows.VerticalAlignment.Top;
title.X = 0.5;
title.Y = maxYVal;
TextBlock titleText = new TextBlock();
titleText.Text = chartName;
var newTitleFont = HelperFunctions.NewTypeFaceFromFont(titleFont);
titleText.FontFamily = newTitleFont.FontFamily;
titleText.FontStyle = newTitleFont.Style;
titleText.FontSize = titleFont.Size;
title.UIElement = titleText;
cartChart.VisualElements.Add(title);
The above code only adds a label on the chart itself (within the y axis range). The title needs to be independent (above the y axis). Any idea?
This seems to do the trick:
public static TableLayoutPanel AddTitleToChart(Control chart,string title, System.Drawing.Font titleFont)
{
Label label = new Label();
label.AutoSize = true;
label.Dock = System.Windows.Forms.DockStyle.Fill;
label.Font = titleFont;
label.Location = new System.Drawing.Point(3, 0);
label.Name = "label1";
label.Size = new System.Drawing.Size(1063, 55);
label.TabIndex = 0;
label.Text = title;
label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
label.BackColor = chart.BackColor;
chart.Dock = System.Windows.Forms.DockStyle.Fill;
TableLayoutPanel tableLayoutPanel = new TableLayoutPanel();
tableLayoutPanel.AutoSize = true;
tableLayoutPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
tableLayoutPanel.BackColor = System.Drawing.Color.White;
tableLayoutPanel.ColumnCount = 1;
tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 1069F));
tableLayoutPanel.Controls.Add(label, 0, 0);
tableLayoutPanel.Controls.Add(chart, 0, 1);
tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
tableLayoutPanel.Location = new System.Drawing.Point(0, 0);
tableLayoutPanel.Name = "tableLayoutPanel1";
tableLayoutPanel.RowCount = 2;
tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle());
tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle());
tableLayoutPanel.Size = new System.Drawing.Size(1069, 662);
tableLayoutPanel.TabIndex = 2;
return (tableLayoutPanel);
}
I'm using LiveCharts in WinForms. Reason why I'm not using WPF is because I don't want to rewrite the GUI in WPF, so I'm trying to see if I can make LiveCharts work in WinForms.
I'm saving the LiveCharts control as an image to a PDF, so the title needs to be on the chart itself.
I cannot find any functionality for adding a title on the chart. What I have tried is the following:
VisualElement title = new VisualElement();
title.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
title.VerticalAlignment = System.Windows.VerticalAlignment.Top;
title.X = 0.5;
title.Y = maxYVal;
TextBlock titleText = new TextBlock();
titleText.Text = chartName;
var newTitleFont = HelperFunctions.NewTypeFaceFromFont(titleFont);
titleText.FontFamily = newTitleFont.FontFamily;
titleText.FontStyle = newTitleFont.Style;
titleText.FontSize = titleFont.Size;
title.UIElement = titleText;
cartChart.VisualElements.Add(title);
The above code only adds a label on the chart itself (within the y axis range). The title needs to be independent (above the y axis). Any idea?
This seems to do the trick:
public static TableLayoutPanel AddTitleToChart(Control chart,string title, System.Drawing.Font titleFont)
{
Label label = new Label();
label.AutoSize = true;
label.Dock = System.Windows.Forms.DockStyle.Fill;
label.Font = titleFont;
label.Location = new System.Drawing.Point(3, 0);
label.Name = "label1";
label.Size = new System.Drawing.Size(1063, 55);
label.TabIndex = 0;
label.Text = title;
label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
label.BackColor = chart.BackColor;
chart.Dock = System.Windows.Forms.DockStyle.Fill;
TableLayoutPanel tableLayoutPanel = new TableLayoutPanel();
tableLayoutPanel.AutoSize = true;
tableLayoutPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
tableLayoutPanel.BackColor = System.Drawing.Color.White;
tableLayoutPanel.ColumnCount = 1;
tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 1069F));
tableLayoutPanel.Controls.Add(label, 0, 0);
tableLayoutPanel.Controls.Add(chart, 0, 1);
tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
tableLayoutPanel.Location = new System.Drawing.Point(0, 0);
tableLayoutPanel.Name = "tableLayoutPanel1";
tableLayoutPanel.RowCount = 2;
tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle());
tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle());
tableLayoutPanel.Size = new System.Drawing.Size(1069, 662);
tableLayoutPanel.TabIndex = 2;
return (tableLayoutPanel);
}
For some reason the tabs inside of my tabControl item in Visual Studio are greyed out. It's not letting me switch from tab to tab and the items inside the tabs are greyed out aswell, so I can't click on anything.
I checked the tabControl settings and the individual tabPages settings and the Locked property is set to "FALSE" so it shouldn't be that.
Any idea what it could be?
Here's the designer.cs code of my tabControl:
// tabControl1
//
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Controls.Add(this.tabPage3);
this.tabControl1.ImageList = this.imageList1;
this.tabControl1.Location = new System.Drawing.Point(12, 12);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(466, 218);
this.tabControl1.TabIndex = 0;
////
// tabPage1
//
this.tabPage1.Controls.Add(this.buttonStopUTUBE);
this.tabPage1.Controls.Add(this.buttonStartUTUBE);
this.tabPage1.Controls.Add(this.numericUpDown1);
this.tabPage1.Controls.Add(this.numericUpDownYouTubeRun);
this.tabPage1.Controls.Add(this.listBoxYoutube5);
this.tabPage1.Controls.Add(this.listBoxYoutube4);
this.tabPage1.Controls.Add(this.listBoxYoutube3);
this.tabPage1.Controls.Add(this.label8);
this.tabPage1.Controls.Add(this.labelYouTubeRunsLeft);
this.tabPage1.Controls.Add(this.label2);
this.tabPage1.Controls.Add(this.label1);
this.tabPage1.ImageIndex = 0;
this.tabPage1.Location = new System.Drawing.Point(4, 28);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(458, 186);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "YouTube Video";
this.tabPage1.UseVisualStyleBackColor = true;
//
// tabPage2
//
this.tabPage2.Controls.Add(this.buttonSTOPWEBSITE);
this.tabPage2.Controls.Add(this.buttonSTARTWEBSITE);
this.tabPage2.Controls.Add(this.listBoxWebsites);
this.tabPage2.Controls.Add(this.richTextBox1);
this.tabPage2.Controls.Add(this.numericUpDownWEBSITE);
this.tabPage2.Controls.Add(this.label9);
this.tabPage2.Controls.Add(this.label5);
this.tabPage2.Controls.Add(this.label3);
this.tabPage2.ImageIndex = 1;
this.tabPage2.Location = new System.Drawing.Point(4, 28);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(458, 186);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "Website";
this.tabPage2.UseVisualStyleBackColor = true;
//
// tabPage3
//
this.tabPage3.Controls.Add(this.button1);
this.tabPage3.Controls.Add(this.txtYPassword);
this.tabPage3.Controls.Add(this.txtYUsername);
this.tabPage3.Controls.Add(this.label12);
this.tabPage3.Controls.Add(this.label7);
this.tabPage3.ImageIndex = 2;
this.tabPage3.Location = new System.Drawing.Point(4, 28);
this.tabPage3.Name = "tabPage3";
this.tabPage3.Padding = new System.Windows.Forms.Padding(3);
this.tabPage3.Size = new System.Drawing.Size(458, 186);
this.tabPage3.TabIndex = 2;
this.tabPage3.Text = "Settings";
this.tabPage3.UseVisualStyleBackColor = true;
//
In my project a have an toolStrip element which behaves strange after modification in Resources.resx file. Doesn't matter what I do: add a new bitmap, delete old bitmap, change Display style of dropdown buttons... Every time I got error messages and no toolStrip at the form.
In my Form.Designer.cs happens next:
Before modification code looks like:
//
// toolStrip1
//
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripDropDownButton1,
this.toolStripSeparator4,
this.toolStripDropDownButton2});
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
this.toolStrip1.Name = "toolStrip1";
this.toolStrip1.Size = new System.Drawing.Size(1584, 27);
this.toolStrip1.TabIndex = 347;
this.toolStrip1.Text = "toolStrip1";
After:
//
// toolStrip1
//
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
this.toolStrip1.Name = "toolStrip1";
this.toolStrip1.Size = new System.Drawing.Size(1584, 27);
this.toolStrip1.TabIndex = 347;
this.toolStrip1.Text = "toolStrip1";
My DropDownButton before modification:
//
// toolStripDropDownButton1
//
this.toolStripDropDownButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.ImageAndText;
this.toolStripDropDownButton1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.openFileToolStripMenuItem,
this.saveCalculationsFileToolStripMenuItem,
this.saveRawCalculationsFileToolStripMenuItem});
this.toolStripDropDownButton1.Image = global::Project_Tribo_v._0._2.Properties.Resources.folder_document;
this.toolStripDropDownButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripDropDownButton1.Name = "toolStripDropDownButton1";
this.toolStripDropDownButton1.Size = new System.Drawing.Size(61, 24);
this.toolStripDropDownButton1.Text = "File";
And after:
//
// toolStripDropDownButton1
//
this.toolStripDropDownButton1.Image = global::Project_Tribo_v._0._2.Properties.Resources.folder_document;
this.toolStripDropDownButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripDropDownButton1.Name = "toolStripDropDownButton1";
this.toolStripDropDownButton1.Size = new System.Drawing.Size(61, 24);
this.toolStripDropDownButton1.Text = "File";
It's not a big problem, while I have small number of toolStrip elements, but stil...
Any ideas how to avoid or repair this?