示例#1
0
 protected virtual void OnSelectedIndexChanging(TabPageIndexEventArgs e)
 {
     if (SelectedIndexChanging != null)
     {
         SelectedIndexChanging(this, e);
     }
 }
示例#2
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            // Raise the SelectedIndexChanging event when the user changes tabs using the keyboard. This is
            // implemented in the base TabControl.OnKeyDown() method (it doesn't use the native Tab Control
            // functionality), so we have to handle it here as well.

            bool processed = false;

            if (e.KeyCode == Keys.Tab && (e.Modifiers & Keys.Control) == Keys.Control)
            {
                bool shift    = ((e.Modifiers & Keys.Shift) == Keys.Shift);
                int  newIndex = (shift ? (SelectedIndex + TabCount - 1) % TabCount : (SelectedIndex + 1) % TabCount);

                TabPageIndexEventArgs args = new TabPageIndexEventArgs(newIndex);
                OnSelectedIndexChanging(args);

                if (args.Cancel)
                {
                    e.Handled = true;
                    processed = true;
                }
            }

            if (!processed)
            {
                base.OnKeyDown(e);
            }
        }
示例#3
0
        private bool WmSelChanging(ref Message m)
        {
            // When the TCN_SELCHANGING notification is received raise an event that allows user code to
            // cancel the selection change.

            int newIndex = HitTest(PointToClient(Control.MousePosition));

            if (newIndex == -1)
            {
                return(false);
            }

            TabPageIndexEventArgs args = new TabPageIndexEventArgs(newIndex);

            OnSelectedIndexChanging(args);

            m.Result = (args.Cancel ? new IntPtr(1) : IntPtr.Zero);

            return(args.Cancel);
        }