Switch to full style
Codes, tips and tricks,discussions and solutions related to C#
Post a reply

Working with menus, Label links and files in C#

Wed Apr 06, 2011 10:23 am

hi, my mentor has asked me to design a form similar to the My Computer Window. am just confused as i dont know how to add those menus and the whole form on the left side.the colored strip with System tasks, other places, details and how they are linked to certain forms and windows like the view system info takes you to the system information window.
deadline is Friday noon.



Re: Working with menus, Label links and files in C#

Wed Apr 06, 2011 10:39 pm

code may help . Form with menu bar .
Code:

using System

using System.Windows.Forms
 
public class 
testForm Form 
  
MainMenu menubarObj
 
  public 
testForm() { 
    
Text "Adding a Main Menu"
 
    
// Create a main menu object. 
    
menubarObj  = new MainMenu(); 
 
    
// Add top-level menu items to the menu. 
    
MenuItem fileMenuIteam = new MenuItem("File"); 
    
menubarObj.MenuItems.Add(fileMenuIteam); 
 
    
MenuItem toolMenuIteam = new MenuItem("Tools"); 
    
menubarObj.MenuItems.Add(toolMenuIteam); 
 
    
// Create File submenu 
    
MenuItem subfileMenuIteam = new MenuItem("Open File"); 
    
fileMenuIteam.MenuItems.Add(subfileMenuIteam); 
 
    
MenuItem subtoolMenuIteam = new MenuItem("Close"); 
    
fileMenuIteam.MenuItems.Add(subtoolMenuIteam); 
 
    
MenuItem exitIteam = new MenuItem("Exit"); 
    
fileMenuIteam.MenuItems.Add(exitIteam); 
 
 
 
    
MenuItem changeIteam = new MenuItem("Change size"); 
    
toolMenuIteam.MenuItems.Add(changeIteam); 
 
    
MenuItem restoreIteam = new MenuItem("Restore size"); 
    
toolMenuIteam.MenuItems.Add(restoreIteam); 
 
 
    
// events call back function 
    
subfileMenuIteam.Click += new EventHandler(openClick); 
    
subtoolMenuIteam.Click += new EventHandler(closeClick); 
    
exitIteam.Click += new EventHandler(exitClick); 
 
    
changeIteam.Click += new EventHandler(changeClick); 
    
restoreIteam.Click += new EventHandler(restoreClick); 
 
    
// set the menu of the form
    
Menu menubarObj
  }   
 
  [
STAThread
  public static 
void Main() { 
    
testForm formObj = new testForm(); 
 
    
Application.Run(formObj); 
  } 
 
  
 
  
// Change action 
  
protected void changeClick(object whoEventArgs e) { 
   
// change size of window
    
Width Height 300
  } 
 
  
// restore action
  
protected void restoreClick(object whoEventArgs e) { 
   
// restore size of window
    
Width Height 400
  } 
 
  
// open selection handling
  
protected void openClick(object whoEventArgs e) { 
 
    
MessageBox.Show("not implemented""not implemented"
                    
MessageBoxButtons.OK); 
  } 
 
  
//  close  click handling
  
protected void closeClick(object whoEventArgs e) { 
 
    
MessageBox.Show("not implemented""not implemented"
                    
MessageBoxButtons.OK); 
  } 
 
  
// exit with confirmation .
  
protected void exitClick(object whoEventArgs e) { 
 
    
DialogResult answer MessageBox.Show("Are you sure you want to exit"
                            
"Exit"
                             
MessageBoxButtons.YesNo); 
 
    if(
answer == DialogResult.YesApplication.Exit(); 
  } 
}

 


Post a reply
  Related Posts  to : Working with menus, Label links and files in C#
 Working with menus, Label links and files in C#     -  
 Label Alignment example     -  
 javap is not working     -  
 SSI.php on other websites, Not working     -  
 HELP: JAVA not working in TEXTPAD     -  
 video conference is nt working     -  
 Working on hotel class     -  
 ScrollableTable is not working in the firefox     -  
 jsp include directive not working     -  
 working of bitwise ~ operator     -