Use toolbox to drop a tab control onto the form; use the tab properties menu (Tab Pages - collection) to create one, or more tab pages and their labels; Right click in the whichever is topmost in the control - you will note that right clicking the mouse within the tab control's page(s) will bring up the properties (or events) menu for the Tab pages - can't set event handlers here - what you have to do is to then left click on one of the tabs - you will see that the properties (or events) menu for the Tab Control is now displayed (see note 1 below). You can now create event handlers for "Enter" and "Selected Index Changed" to give you the notifications you will most likely want to use use in your code - the "Enter" event occurs when the tab control (regardless of whichever page is topmost) receives the focus; the "Selected Index Changed" event occurs when you click on a tab different than the one that is currently topmost. Note 1: If you are displaying a Tab Page's properties (or events) menu (say for page 2) and you then left click on the page 2 tab to switch to the Tab Control menus you may find that it won't switch - have no fear, simply left click on a different tab. If you have a one tab control then click on the blank space immediately to the right of the tab. A VERY simple example of a do-nothing "Selected Index Changed" event handler is: private void tabControl1_SelectedIndexChanged(object sender, System.EventArgs e) { int index=tabControl1.SelectedIndex; // Tab Control's tab index (0 relative) int tabIndex=tabControl1.TabIndex; // KB tab-key order string str = String.Format("tabControl2_SelectedIndexChanged selectedIndex={0} tabIndex={1}", index,tabIndex); MessageBox.Show(str); } Hope this helps. Spolia Opima
spolia
Posts
-
Tab Control Events Not Firing -
Is there a way to make native win32 call?Michel, here's an example for you. You can group the import specs as shown here, or interspersed through your code... class Win32 { [DllImport("kernel32.dll")] public static extern bool Beep(int freq, int duration); [DllImport("kernel32.dll")] public static extern void SleepEx(int imeinms, int alert); [DllImport("kernel32.dll")] public static extern int WinExec(string pgmname, int hideorshow); [DllImport("kernel32.dll")] public static extern void ExitProcess(uint exitCode); [DllImport("winmm.dll")] public static extern bool PlaySound(string pszSound, int hmod, uint fdwSound); [DllImport("kernel32.dll")] public static extern uint GetCurrentProcess(); [DllImport("kernel32.dll")] public static extern bool TerminateProcess(uint hndl, uint exitcode); } call the functions from your code (say the Beep function) as: Win32.Beep(freq,duration); Hope this helps. Spolia Opima