【发布时间】:2013-09-05 04:44:46
【问题描述】:
我正在尝试在我的 vb.net 程序中使用下面的组件
我遇到的问题是错误提示SuspendLayout 不是FlatTabControl.FlatTabControl 的成员,即使Controls 不是FlatTabControl 的成员。
有人知道如何解决这个问题吗?
下面是我转换成 VB.Net 代码的 C# 代码,仍然无法正常工作。
干杯。
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace TabControlTest
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private FlatTabControl.FlatTabControl tabControl1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.TabPage tabPage3;
private System.Windows.Forms.TabPage tabPage4;
private System.ComponentModel.IContainer components;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (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.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.tabControl1 = new FlatTabControl.FlatTabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.tabPage4 = new System.Windows.Forms.TabPage();
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.tabControl1.SuspendLayout();
this.SuspendLayout();
//
// tabControl1
//
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Controls.Add(this.tabPage3);
this.tabControl1.Controls.Add(this.tabPage4);
this.tabControl1.ImageList = this.imageList1;
this.tabControl1.Location = new System.Drawing.Point(8, 16);
this.tabControl1.myBackColor = System.Drawing.SystemColors.Control;
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 2;
this.tabControl1.Size = new System.Drawing.Size(328, 240);
this.tabControl1.TabIndex = 0;
//
// tabPage1
//
this.tabPage1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(224)))), ((int)(((byte)(192)))));
this.tabPage1.ImageIndex = 0;
this.tabPage1.Location = new System.Drawing.Point(4, 25);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Size = new System.Drawing.Size(320, 211);
this.tabPage1.TabIndex = 1;
this.tabPage1.Text = "tabPage1";
//
// tabPage2
//
this.tabPage2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
this.tabPage2.ImageIndex = 1;
this.tabPage2.Location = new System.Drawing.Point(4, 25);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Size = new System.Drawing.Size(192, 71);
this.tabPage2.TabIndex = 0;
this.tabPage2.Text = "tabPage2";
//
// tabPage3
//
this.tabPage3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
this.tabPage3.ImageIndex = 2;
this.tabPage3.Location = new System.Drawing.Point(4, 25);
this.tabPage3.Name = "tabPage3";
this.tabPage3.Size = new System.Drawing.Size(192, 71);
this.tabPage3.TabIndex = 2;
this.tabPage3.Text = "tabPage3";
//
// tabPage4
//
this.tabPage4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
this.tabPage4.ImageIndex = 0;
this.tabPage4.Location = new System.Drawing.Point(4, 25);
this.tabPage4.Name = "tabPage4";
this.tabPage4.Size = new System.Drawing.Size(192, 71);
this.tabPage4.TabIndex = 3;
this.tabPage4.Text = "tabPage4";
//
// imageList1
//
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
this.imageList1.Images.SetKeyName(0, "");
this.imageList1.Images.SetKeyName(1, "");
this.imageList1.Images.SetKeyName(2, "");
//
// button2
//
this.button2.Location = new System.Drawing.Point(352, 160);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 2;
this.button2.Text = "Add";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Location = new System.Drawing.Point(352, 208);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 23);
this.button3.TabIndex = 3;
this.button3.Text = "Remove";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(448, 269);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.tabControl1);
this.Name = "Form1";
this.Text = "FlatTabControl test";
this.Load += new System.EventHandler(this.Form1_Load);
this.tabControl1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
}
private static int nt = 0;
private void button2_Click(object sender, System.EventArgs e)
{
TabPage tabPage = new System.Windows.Forms.TabPage("newTab");
switch (nt)
{
case 0:
{
tabPage.BackColor = Color.LightCoral;
tabPage.ImageIndex = 0;
nt = 1;
}
break;
case 1:
{
tabPage.BackColor = Color.LightGoldenrodYellow;
tabPage.ImageIndex = 1;
nt = 2;
}
break;
case 2:
{
tabPage.BackColor = Color.LightSeaGreen;
tabPage.ImageIndex = 2;
nt = 0;
}
break;
}
tabControl1.TabPages.Add(tabPage);
}
private void button3_Click(object sender, System.EventArgs e)
{
tabControl1.TabPages.RemoveAt(tabControl1.SelectedIndex);
}
private void tabControl1_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
{
MessageBox.Show("1");
}
}
}
【问题讨论】:
-
这似乎是 .Net C#... 也许您的意思是将 C# 转换为 VB.Net?如果是这样,请包括您的 vb 代码。
-
你为什么不创建一个新的 c#-project 并将这个控件放在里面。然后在您的 VB 解决方案中,您应该能够引用 ControlDll 并使用控件
-
您从哪里获得 FlatTabControl?它是第三方控件,所以您可能只是忘记添加对包含该控件代码的程序集/dll 的引用?
-
@BrutalDev 它在 codeproject 上,有一个链接...是的,只是参考它...
-
将 C# 转换为 .NET .... 嗯.... C# IS 一种 .NET 语言, 绝对不需要转换任何东西....
标签: c# vb.net tabcontrol