TabControl tabpage change 
Author Message
 TabControl tabpage change

There is a TabIndexChanged event for handling things after changed.
How can I handle the (pre-change) event when user click a tabpage but
if some codition is not met, then user can not change to anywhere.
What event should I use? Thanx


Wed, 23 Mar 2005 02:13:06 GMT  
 TabControl tabpage change
Joe,

Add event hadler for Click event for each individual tab page:
//
// tabControl1
//
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Location = new System.Drawing.Point(128, 136);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.TabIndex = 1;
//
// tabPage1
//
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Size = new System.Drawing.Size(192, 74);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "tabPage1";
this.Click += new EventHandler(Form1_Click);

--

Hope this Helps.

Ryan Dawson


Quote:
> There is a TabIndexChanged event for handling things after changed.
> How can I handle the (pre-change) event when user click a tabpage but
> if some codition is not met, then user can not change to anywhere.
> What event should I use? Thanx



Wed, 23 Mar 2005 05:29:51 GMT  
 TabControl tabpage change
try the TabPage's "Validating" event.

mike

--
 This posting is provided "AS IS" with no warranties, and confers no rights


Quote:
> There is a TabIndexChanged event for handling things after changed.
> How can I handle the (pre-change) event when user click a tabpage but
> if some codition is not met, then user can not change to anywhere.
> What event should I use? Thanx



Wed, 23 Mar 2005 05:32:24 GMT  
 TabControl tabpage change
Well, the TabControl sends a TCN_SELCHANGING. notification message to the
parent window when you're about to change the active index. You can handle
this message and return TRUE to prevent the selection from changing or
FALSE to allow the selection to change. Unfortunately WinForms
implementation fires an event only for TCN_SELCHANGE
(it's TabIndexChanged) and it occurs when the active tab has been changed
already. Here is a sample code how to handle TCN_SELCHANGING:

[StructLayout(LayoutKind.Sequential)]
struct NMHDR
{
    public IntPtr hwndFrom;
    public uint idFrom;
    public uint code;

Quote:
};

protected override void WndProc(ref System.Windows.Forms.Message m)
{
    const uint WM_NOTIFY = 0x004E;
    const uint TCN_FIRST = 0xFFFFFDDA;
    const uint TCN_SELCHANGING = TCN_FIRST - 2;

    base.WndProc(ref m);

    switch ((uint)m.Msg)
   {
        case WM_NOTIFY:
       {
            int idCtrl = (int)m.WParam;
            NMHDR nmh = (NMHDR)m.GetLParam(typeof(NMHDR));
           if (nmh.code == TCN_SELCHANGING)
           {
                MessageBox.Show("TCN_SELCHANGING");
           }
           m.Result = (IntPtr)1;
           break;
      }
   }

Quote:
}

BL


Quote:
> There is a TabIndexChanged event for handling things after changed.
> How can I handle the (pre-change) event when user click a tabpage but
> if some codition is not met, then user can not change to anywhere.
> What event should I use? Thanx



Wed, 23 Mar 2005 08:41:06 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. dynamically adding separately created tabpage to tabcontrol

2. how CFormView transfer values to it′s tabcontrol and in it embeded tabpages

3. TabControl/TabPages

4. Catching the TabPage change event?

5. How to change TabControl styles?

6. TabPage question

7. How to display richtextbox scrollbars on a tabpage?

8. Newbit: help with TabPage and Controls

9. Adding objects to a tabpage programmitically

10. Broken Show() and Hide() for Forms.Form.TabPage

11. Hide a TabPage

12. is it possible to show Form on TabPage ?

 

 
Powered by phpBB® Forum Software