Re: ActivePart

Re: ActivePart

Old forum URL: forums.lhotka.net/forums/t/3641.aspx


ozitraveller posted on Wednesday, October 03, 2007

Hi

Has anyone got a better way to do this?

I want to add some menu options which might/might not be available on the WinPart derived controls. Eg export data in the control to a csv, so I added CanExport property which is overriden in the control. And set ActiveWinPart in the ShowWinPart method see below. This will be me a way to export from what ever the ActiveWinPart is.

    public partial class WinPart : UserControl
    {
        private static WinPart _winPart = null;

        public WinPart()
        {
            InitializeComponent();
        }

        public virtual bool CanExport
        {
            get
            {
                return false;
            }
        }

        public static WinPart ActivePart
        {
            get
            {
                return _winPart;
            }
            set
            {
                _winPart = value;
            }
        }

 

 

        private void ShowWinPart(WinPart part)
        {
            WinPart.ActivePart = part;
            part.Dock = DockStyle.Fill;
            part.Visible = true;
            part.BringToFront();
            this.Text = string.Format("{0} - {1}", _assemblyTitle, part.ToString());
        }

Copyright (c) Marimer LLC