Click here to Skip to main content
       

C#

 
QuestionHow to use IWin32Window Pinmembermhd almidani1-Apr-13 0:31 
AnswerRe: How to use IWin32Window PinmvpEddy Vluggen1-Apr-13 1:03 
GeneralRe: How to use IWin32Window Pinmembermhd almidani1-Apr-13 6:09 
GeneralRe: How to use IWin32Window PinmemberAlan N1-Apr-13 6:24 
GeneralRe: How to use IWin32Window Pinmembermhd almidani1-Apr-13 21:35 
GeneralRe: How to use IWin32Window PinmvpEddy Vluggen1-Apr-13 12:34 
AnswerRe: How to use IWin32Window PinmvpRichard MacCutchan1-Apr-13 1:03 
QuestionCustom TabControl: Designer adds TabPages in wrong order! [modified] PinmemberRevolty31-Mar-13 10:33 
Hey
 
I've a custom TabControl that inherites Forms.UserControl, not Forms.TabControl. This shall behave just as a normal TabControl codewice. The issue is that TabPages beeing added in the wrong order by the designer. At first it is ok, 2 pages beeing added as expected, #1 and then #2, but when I make any changes to a Page #2, the Text for example - Page #2 beeing added as #1 in designer (the order is now incorrect):
 
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Controls.Add(this.tabPage1);
 
Pages beeing added like this in my control:
 
protected override void OnControlAdded(ControlEventArgs e)
{
    base.OnControlAdded(e);
 
    m_Pages.Add(e.Control as TabPage);
}
 
And the control designer looks like this:
 
public class TabControlDesigner : ParentControlDesigner
{
    private DesignerVerbCollection m_Verbs;
 
    public override void InitializeNewComponent(IDictionary defaultValues)
    {
        base.InitializeNewComponent(defaultValues);
 
        OnAddTabPage(this, EventArgs.Empty);
        OnAddTabPage(this, EventArgs.Empty); 
    }
 
    public override DesignerVerbCollection Verbs
    {
        get
        {
            return m_Verbs != null ? m_Verbs : m_Verbs = new DesignerVerbCollection(new DesignerVerb[] { new DesignerVerb("Add Tab", OnAddTabPage) });
        }
    }
 
    protected void OnAddTabPage(Object sender, EventArgs e)
    {
        IDesignerHost Host = (IDesignerHost)GetService(typeof(IDesignerHost));
 
        if (Host == null)
            return;
 
        TabControl Control = Component as TabControl;
 
        if (Control == null)
            return;
 
        TabPage newPage = Host.CreateComponent(typeof(TabPage)) as TabPage;
 
        MemberDescriptor Descriptor = TypeDescriptor.GetProperties(Control)["Controls"];
 
        RaiseComponentChanging(Descriptor);
 
        newPage.Text = newPage.Name;
        newPage.Owner = Component as TabControl;
        newPage.BackColor = Color.White;
 
        Control.Controls.Add(newPage);
                
        RaiseComponentChanged(Descriptor, null, null);
    }
 
    public override bool CanParent(Control c)
    {
        if (c is TabPage)
            return !Control.Contains(c);
        else
            return false;
    }
 
    protected override void WndProc(ref Message m)
    { 
        if (m.Msg == 0x201 /*WM_LBUTTONDOWN*/)
        {
            TabControl c = Component as TabControl;
 
            int lParam = m.LParam.ToInt32();
            Point p = new Point(lParam & 0xffff, lParam >> 0x10);
 

            for (int i = 0; i < c.Controls.Count; i++)
            {
                 if (c.GetTabRect(i).Contains(p))
                 {
                     c.SelectedIndex = i;
                     return;
                 }
            }
            
        }
 
        base.WndProc(ref m);
    }
 
    protected override void OnDragDrop(DragEventArgs e)
    {
        ((IDropTarget)((TabControl)Component).SelectedPage).OnDragDrop(e);
    }
 
    protected override void OnDragEnter(DragEventArgs e)
    {
        ((IDropTarget)((TabControl)Component).SelectedPage).OnDragEnter(e);
    }
 
    protected override void OnDragLeave(EventArgs e)
    {
        ((IDropTarget)((TabControl)Component).SelectedPage).OnDragLeave(e);
    }
 
    protected override void OnDragOver(DragEventArgs e)
    {
        ((IDropTarget)((TabControl)Component).SelectedPage).OnDragOver(e);
    }
}        


modified 31-Mar-13 16:58pm.

AnswerRe: Custom TabControl: Designer adds TabPages in wrong order! PinmemberRevolty7-Apr-13 6:18 
Questionكيف البحث عن ملفات محرر التسجيل Pinmemberreemaziz31-Mar-13 7:13 
AnswerRe: كيف البحث عن ملفات محرر التسجيل PinmemberKenneth Haugland31-Mar-13 7:49 
AnswerRe: كيف البحث عن ملفات محرر التسجيل PinmvpRichard MacCutchan31-Mar-13 9:02 
Questioninsatling mssql server 2008r2 PinmemberAshbinsapkota31-Mar-13 6:39 
AnswerRe: insatling mssql server 2008r2 PinprotectorPete O'Hanlon31-Mar-13 6:52 
AnswerRe: insatling mssql server 2008r2 PinmvpAbhinav S31-Mar-13 23:40 
QuestionSqlDependency. Can't realize. PinmemberMember 995500631-Mar-13 1:05 
AnswerRe: SqlDependency. Can't realize. PinmvpEddy Vluggen31-Mar-13 1:31 
GeneralRe: SqlDependency. Can't realize. PinmemberJeka Developer1-Apr-13 3:43 
AnswerRe: SqlDependency. Can't realize. PinmvpEddy Vluggen1-Apr-13 3:55 
GeneralRe: SqlDependency. Can't realize. PinmemberJeka Developer1-Apr-13 5:57 
GeneralRe: SqlDependency. Can't realize. PinmvpEddy Vluggen1-Apr-13 12:41 
GeneralRe: SqlDependency. Can't realize. PinmemberJeka Developer2-Apr-13 11:24 
GeneralRe: SqlDependency. Can't realize. PinmvpEddy Vluggen3-Apr-13 7:52 
AnswerRe: SqlDependency. Can't realize. Pinmemberjschell1-Apr-13 9:12 
GeneralRe: SqlDependency. Can't realize. PinmemberJeka Developer2-Apr-13 11:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 20 Dec 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid