• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
一天到晚游泳的鱼
博客园    首页    新随笔    联系   管理    订阅  订阅

winform 动态添加选项卡

///   <summary> 
///   添加信息显示选项卡 
///   </summary> 
public   TabPage   AddPage() 
{ 
TabPage   tabPage   
=   new   TabPage(); 
RichTextBox   richTextBox   
=   new   RichTextBox(); 

this.tabControl1.Controls.Add(tabPage); 
int   count   =   this.tabControl1.Controls.Count; 
tabPage.Controls.Add(richTextBox); 
tabPage.Location   
=   new   System.Drawing.Point(4,   4); 
tabPage.Name   
=   "tabPage "   +   count.ToString(); 
tabPage.Size   
=   new   System.Drawing.Size(480,   271); 
tabPage.TabIndex   
=   this.tabControl1.Controls.Count; 
tabPage.Text   
=   "tabPage "   +   count.ToString(); 


richTextBox.Anchor   
=   ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top   |   System.Windows.Forms.AnchorStyles.Bottom)   
|   System.Windows.Forms.AnchorStyles.Left)   
|   System.Windows.Forms.AnchorStyles.Right))); 
richTextBox.Location   
=   new   System.Drawing.Point(0,   0); 
richTextBox.Name   
=   "richTextBox "   +   count.ToString(); 
richTextBox.Size   
=   new   System.Drawing.Size(480,   264); 
richTextBox.TextChanged   
+=   new   System.EventHandler(this.richTextBoxInfo_TextChanged); 
richTextBox.TabIndex   
=   0; 
richTextBox.Text   
=   " "; 
return   tabPage; 
}
void richTextBox_TextChanged(object sender, EventArgs e)
{
    RichTextBox richTextBox 
= (RichTextBox) sender;
    MessageBox.Show(richTextBox.Name);
}
posted @ 2011-04-08 18:04  Pato'  阅读(2559)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3