日期:2014-05-17  浏览次数:21269 次

c# 在TabControl上添加按钮,要求按钮在tabPage的右部。
c# 在TabControl上添加按钮,要求按钮在tabPage的右部。
说白了,用程序描述就是TabControl.Controls.Add(new Button()),但实际上这条程序是不对的。
而且要求该button的位置在tabPage标签的正右部,又包含在TabControl里。
没办法,客户要求的。。。
请教各位大侠啦,谢谢!

------解决方案--------------------
你这个只能用重绘,或者算坐标,把BUTTON的位置放到你想要的地方~~
------解决方案--------------------
引用:
你这个只能用重绘,或者算坐标,把BUTTON的位置放到你想要的地方~~

------解决方案--------------------
你开发控件的?
重写TabControl的Onpaint函数

如果不是,你自己加个按钮,用方向键,移到Tabcontrol上即可。
------解决方案--------------------
重写TabControl,,网上有很多重写TabControl的代码,你可以参考一下
------解决方案--------------------
C#重绘TabControl的Tabpage标签,添加图片及关闭按钮 

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; 
  
namespace WindowsFormsApplication1.june 

    public partial class TabTest : Form 
    { 
        public TabTest() 
        { 
            InitializeComponent(); 
        } 
  
        private void TabTest_Load(object sender, EventArgs e) 
        { 
            //清空控件 
            //this.MainTabControl.TabPages.Clear(); 
            //绘制的方式OwnerDrawFixed表示由窗体绘制大小也一样 
            this.MainTabControl.DrawMode = TabDrawMode.OwnerDrawFixed; 
            this.MainTabControl.Padding = new System.Drawing.Point(CLOSE_SIZE, CLOSE_SIZE); 
            this.MainTabControl.DrawItem += new DrawItemEventHandler(this.MainTabControl_DrawItem); 
            this.MainTabControl.MouseDown += new System.Windows.Forms.MouseEventHandler(this.MainTabControl_MouseDown); 
        } 
  
        const int CLOSE_SIZE = 15; 
        //tabPage标签图片 
        Bitmap image = new Bitmap("E:\\ico_close.gif"); 
  
        //绘制“X”号即关闭按钮 
        private void MainTabControl_DrawItem(object sender, DrawItemEventArgs e) 
        { 
            try