Click here to Skip to main content
       

C#

 
AnswerRe: Read PDF PinmvpAbhinav S1-Apr-13 20:47 
QuestionFavorites from HTML PinmemberMAW301-Apr-13 12:15 
AnswerRe: Favorites from HTML PinmvpEddy Vluggen1-Apr-13 13:20 
QuestionOpenOffice API for DotNet PinmemberASPnoob1-Apr-13 6:45 
AnswerRe: OpenOffice API for DotNet PinmemberThePhantomUpvoter1-Apr-13 7:13 
QuestionEach page of report viewer contain single report(.rdlc) [modified] PinmemberM. K. BASHER1-Apr-13 2:23 
QuestionHow to use IWin32Window Pinmembermhd almidani31-Mar-13 23:31 
AnswerRe: How to use IWin32Window PinmvpEddy Vluggen1-Apr-13 0:03 
GeneralRe: How to use IWin32Window Pinmembermhd almidani1-Apr-13 5:09 
GeneralRe: How to use IWin32Window PinmemberAlan N1-Apr-13 5:24 
GeneralRe: How to use IWin32Window Pinmembermhd almidani1-Apr-13 20:35 
GeneralRe: How to use IWin32Window PinmvpEddy Vluggen1-Apr-13 11:34 
AnswerRe: How to use IWin32Window PinmvpRichard MacCutchan1-Apr-13 0:03 
QuestionCustom TabControl: Designer adds TabPages in wrong order! [modified] PinmemberRevolty31-Mar-13 9: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 5:18 
Questionكيف البحث عن ملفات محرر التسجيل Pinmemberreemaziz31-Mar-13 6:13 
AnswerRe: كيف البحث عن ملفات محرر التسجيل PinmemberKenneth Haugland31-Mar-13 6:49 
AnswerRe: كيف البحث عن ملفات محرر التسجيل PinmvpRichard MacCutchan31-Mar-13 8:02 
Questioninsatling mssql server 2008r2 PinmemberAshbinsapkota31-Mar-13 5:39 
AnswerRe: insatling mssql server 2008r2 PinprotectorPete O'Hanlon31-Mar-13 5:52 
AnswerRe: insatling mssql server 2008r2 PinmvpAbhinav S31-Mar-13 22:40 
QuestionSqlDependency. Can't realize. PinmemberMember 995500631-Mar-13 0:05 
AnswerRe: SqlDependency. Can't realize. PinmvpEddy Vluggen31-Mar-13 0:31 
GeneralRe: SqlDependency. Can't realize. PinmemberJeka Developer1-Apr-13 2:43 
AnswerRe: SqlDependency. Can't realize. PinmvpEddy Vluggen1-Apr-13 2:55 
GeneralRe: SqlDependency. Can't realize. PinmemberJeka Developer1-Apr-13 4:57 
GeneralRe: SqlDependency. Can't realize. PinmvpEddy Vluggen1-Apr-13 11:41 
GeneralRe: SqlDependency. Can't realize. PinmemberJeka Developer2-Apr-13 10:24 
GeneralRe: SqlDependency. Can't realize. PinmvpEddy Vluggen3-Apr-13 6:52 
AnswerRe: SqlDependency. Can't realize. Pinmemberjschell1-Apr-13 8:12 
GeneralRe: SqlDependency. Can't realize. PinmemberJeka Developer2-Apr-13 10:26 
QuestionSNMP PinmemberSahar.H30-Mar-13 22:05 
AnswerRe: SNMP PinprotectorPete O'Hanlon30-Mar-13 23:09 
QuestionRegarding class instance and memory allocation c# PinmemberTridip Bhattacharjee30-Mar-13 20:33 
AnswerRe: Regarding class instance and memory allocation c# PinmvpEddy Vluggen31-Mar-13 1:12 
GeneralRe: Regarding class instance and memory allocation c# PinmemberTridip Bhattacharjee1-Apr-13 4:29 
GeneralRe: Regarding class instance and memory allocation c# PinmvpEddy Vluggen1-Apr-13 11:49 
AnswerRe: Regarding class instance and memory allocation c# PinmemberPIEBALDconsult31-Mar-13 4:48 
QuestionWCF file upload functionality and message contract usage PinmemberTridip Bhattacharjee30-Mar-13 19:52 
QuestionControl when to display something in a projector Pinmemberdrazen1230-Mar-13 17:26 
AnswerRe: Control when to display something in a projector PinmvpOriginalGriff30-Mar-13 21:56 
QuestionNumber slider puzzle solver code c# Pinmemberjebreil 64429-Mar-13 19:00 
AnswerRe: Number slider puzzle solver code c# PinmemberKenneth Haugland29-Mar-13 21:40 
GeneralRe: Number slider puzzle solver code c# Pinmemberharold aptroot29-Mar-13 23:17 
QuestionBack and Forward Button for windows explorer Pinmemberbaharan2029-Mar-13 10:42 
AnswerRe: Back and Forward Button for windows explorer PinmemberTyler Candee29-Mar-13 10:50 
GeneralRe: Back and Forward Button for windows explorer Pinmemberbaharan2029-Mar-13 11:14 
AnswerRe: Back and Forward Button for windows explorer PinmvpEddy Vluggen31-Mar-13 1:15 
QuestionOSPF in the WSN Pinmembertraidat199229-Mar-13 7:11 
AnswerRe: OSPF in the WSN PinprotectorPete O'Hanlon29-Mar-13 8:25 

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
Web03 | 2.8.140916.1 | Last Updated 21 Sep 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid