In a nut shell, I am trying to inherit System.Windows.Forums.TabControl & ...TabPage. I order to add a custom prop field. Now all indications point to it working. (IntelliSence displays custom prop, and the form designer indicates the inherited control is correctly being used)
How ever <tabcontrolername>.SelectedTab.<customprop> is always blank (null).
In order to spare you all the ins and outs, I created a generic project describing what I'm trying to do. In the sample the custom prop is a string (to keep it simple), however in the real app it's an instance of a custom struct.
So, any ideas as to what I'm doing wrong?
Base form code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace TabStorage
{
public partial class fmMain : Form
{
public fmMain()
{
InitializeComponent();
}
private void btNew_Click(object sender, EventArgs e)
{
NTabPage np = new NTabPage();
np.Text = "New Tab";
np.PageMode = "Custom Tab Prop String";
tcTabControl.TabPages.Add(np);
np = null;
}
private void btInfo_Click(object sender, EventArgs e)
{
MessageBox.Show(tcTabControl.SelectedTab.PageMode);
}
}
}
Win Forms Designer code:
namespace TabStorage
{
partial class fmMain
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btNew = new System.Windows.Forms.Button();
this.btInfo = new System.Windows.Forms.Button();
this.tcTabControl = new TabStorage.NTabControl();
this.SuspendLayout();
//
// btNew
//
this.btNew.Location = new System.Drawing.Point(0, 12);
this.btNew.Name = "btNew";
this.btNew.Size = new System.Drawing.Size(75, 23);
this.btNew.TabIndex = 0;
this.btNew.Text = "New Tab";
this.btNew.UseVisualStyleBackColor = true;
this.btNew.Click += new System.EventHandler(this.btNew_Click);
//
// btInfo
//
this.btInfo.Location = new System.Drawing.Point(0, 41);
this.btInfo.Name = "btInfo";
this.btInfo.Size = new System.Drawing.Size(75, 23);
this.btInfo.TabIndex = 1;
this.btInfo.Text = "Get Info";
this.btInfo.UseVisualStyleBackColor = true;
this.btInfo.Click += new System.EventHandler(this.btInfo_Click);
//
// tcTabControl
//
this.tcTabControl.Location = new System.Drawing.Point(81, 12);
this.tcTabControl.Name = "tcTabControl";
this.tcTabControl.PageMode = null;
this.tcTabControl.SelectedIndex = 0;
this.tcTabControl.Size = new System.Drawing.Size(229, 328);
this.tcTabControl.TabIndex = 2;
//
// fmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(322, 352);
this.Controls.Add(this.tcTabControl);
this.Controls.Add(this.btInfo);
this.Controls.Add(this.btNew);
this.Name = "fmMain";
this.Text = "Tab Storage";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button btNew;
private System.Windows.Forms.Button btInfo;
private NTabControl tcTabControl;
}
public class NTabControl : System.Windows.Forms.TabControl
{
private string m_PageMode;
private NTabPage m_TabPage = new NTabPage();
public string PageMode
{
get { return m_PageMode; }
set { m_PageMode = value; }
}
public new NTabPage SelectedTab
{
get { return m_TabPage; }
set { m_TabPage = value; }
}
}
public class NTabPage : System.Windows.Forms.TabPage
{
private string m_PageMode;
public string PageMode
{
get { return m_PageMode; }
set { m_PageMode = value; }
}
}
}
yes, which is especially funny considering you no longer have an option to turn them off, so how could this matter to anyone?
It would be pretty evil if they waited until after Windows 10 EOL to renew the certs, but based on these dates, it looks like that wouldn't be possible, so no worries that I can see.
I think they needed to simplify their product lines, having such a range of devices is confusing at best, and yes, I think it's also worth dropping those old line names. So I think it's good for them in the long run, and I bet they found that in their research too.
Ask a random consumer which of their products would have been the premium one, and unless they knew Dell products intimately, I doubt they would know. Though I think they could have simplified it further.. "Pro Max Plus", what the hell is going on there?!
Question
KXM
I hit a wall...
In a nut shell, I am trying to inherit System.Windows.Forums.TabControl & ...TabPage. I order to add a custom prop field. Now all indications point to it working. (IntelliSence displays custom prop, and the form designer indicates the inherited control is correctly being used)
How ever <tabcontrolername>.SelectedTab.<customprop> is always blank (null).
In order to spare you all the ins and outs, I created a generic project describing what I'm trying to do. In the sample the custom prop is a string (to keep it simple), however in the real app it's an instance of a custom struct.
So, any ideas as to what I'm doing wrong?
Base form code:
Win Forms Designer code:
The full poroject in a zip.
TabStorage.zipFetching info...
Link to comment
https://www.neowin.net/forum/topic/442553-c-inherting-tabpage-tabcontrol/Share on other sites
4 answers to this question
Recommended Posts