我已经添加了我的主类,我从中调用按钮类,这就是它应该打印出按钮的地方。代码编译正常,但我看不到实际的按钮。在我看来,它没有继承控件属性。谢谢!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows;
//main class
namespace Test
{
public partial class Form1 : Form
{
buttons button1;
public Form1()
{
InitializeComponent();
print_button();
}
private void print_button()
{
button1 = new buttons();
button1.print();
}
}//form
}//test
//---------------------------------------------------------------//
//buttons class
namespace Test
{
public class buttons : System.Windows.Forms.Control
class buttons
{
private Button button1;
public buttons()
{
}
public void print()
{
button1 = new Button();
button1.Location = new System.Drawing.Point(82, 44);
button1.Size = new System.Drawing.Size(977, 54);
button1.Text = "next";
Controls.Add(button1);
}
}//class
}//test