Graphical User Interface

  • Implemented Things:

    • Form :

      • Properties:

        • Accept Button
        • Auto Scroll
        • Cancel Button
        • Form Border Style
      • Methods:

        • Close
        • Hide
        • Show
      • To set a form in a fixed sizes the max. size & min. size should be equals or set the Form Border Style property to Fixed Single
    • Controls:

      • Properties:

        • Focused
        • Tab Index
        • Visible
        • Anchor: make control remaining at a fixed distance from the sides of form
        • Dock: Allow control to span one side of it’s container
        • Padding: specifies the distance between docked controls and form edge
        • Border Style: the style of the control borders
      • Methods:

        • Focus
        • Hide
        • Show
  • Expressions:

    • Snap Lines: the blue lines
  • Textbox:

    • Password Character
    • Accept Return:

      • True: Pressing enter creates new line
      • False: Pressing enter activate the default accept button of the form
  • Button:

    • Flat Style:

      • Flat: usual
      • Popup: colored when the mouse over it
      • Standard: 3-D
  • GroupBoxes and Panels arrange controls on a GUI. GroupBoxes and Panels are typically used to group several controls of similar functionality or several controls that are related in a GUI. All of the controls in a GroupBox or Panel move together when the GroupBox or Panel is moved. The primary difference between these two controls is that GroupBoxes can display a caption (i.e., text) and do not include scrollbars, whereas Panels can include scrollbars and do not include a caption
  • GroupBox:

    • Properties:

      • Controls: the set of controls the group contains
  • Panel:

    • Properties:

      • Indicates whether scrollbars appear when the Panel is too small to display all of its controls. The default value is false
  • C# has two types of state buttons that can be in the on/off or true/false states CheckBoxes and RadioButtons. Like class Button, classes CheckBox and RadioButton are derived from class ButtonBase
  • CheckBox:

    • Properties:

      • Checked
      • Check State: Determine the state of it with the Indeterminate state
  • To change the font style on a Label, you must set its Font property to a new Font object
  • Styles can be combined via bitwise operator that perform manipulation on bits of information
  • The advantages of using bitwise operators to combine FontStyle values become more evident when we consider that there are five different FontStyle values (Bold, Italic, Regular, Strikeout and Underline), resulting in 16 different FontStyle combinations. Using bitwise operators to combine font styles greatly reduces the amount of code required to check all possible font combinations
  • RadioButtons are used to represent a set of mutually exclusive options
  • Object iconType is of type MessageBoxIcon, and can have values Asterisk, Error, Exclamation, Hand, Information, None, Question, Stop and Warning
  • Object buttonType is of type MessageBoxButtons, and can have values AbortRetryIgnore, OK, OKCancel, RetryCancel, YesNo and YesNoCancel
  • PictureBox:

    • Properties:

      • Image: set the image
      • Size Mode: Normal, Stretch, Auto Size, Center …
  • Tool Tips

    • Many programs use tool tips to remind users of each control’s purpose
    • Properties:

      • Auto Pop Delay: The amount of time (in milliseconds) that the tool tip appears while
        the mouse is over a control
      • Initial Delay: The amount of time (in milliseconds) that a mouse must hover over a control before a tool tip appears
      • Reshow Delay: The amount of time (in milliseconds) between which two different tool tips appear (when the mouse is moved from one control to another)
    • Events:

      • Draw:     rose when the tool tip is displayed. This event allows programmers to modify the appearance of the tool tip
  • NumericUpDown:

    • At times, we will want to restrict a user’s input choices to a specific range of numeric values. This is the purpose of the NumericUpDown control
    • Properties:

      • Increment: Specifies by how much the current number in the control changes when the user clicks the control’s up and down arrows
      • Maximum, Minimum: largest and lowest values
      • Up down Align: Modifies the alignment of the up and down Buttons on the NumericUpDown control. This property can be used to display these Buttons either to the left or to the right of the control
      • Value: the current value
    • Events:

      • Value Changed
  • Here we explain how to handle mouse events, such as clicks, presses and moves, which are generated when the user interacts with a control via the mouse. Mouse events can be handled for any control that derives from class System.Windows.Forms.Control. For most mouse events, information about the event is passed to the event-handling method through an object of class MouseEventArgs, and the delegate used to create the mouseevent handlers is MouseEventHandler. Each mouse-event-handling method for these events requires an object and a MouseEventArgs object as arguments.
  • Class MouseEventArgs contains information related to the mouse event, such as the mouse pointer’s x- and y-coordinates, the mouse button pressed (Right, Left or Middle) and the number of times the mouse was clicked. Note that the x- and y-coordinates of the MouseEventArgs object are relative to the control that generated the eventi.e., point (0,0) represents the upper-left corner of the control where the mouse event occurred
  • Properties:

    • Mouse Events with Event Argument of Type EventArgs

      • Mouse Enter: Occurs when the mouse cursor enters the control’s boundaries
      • Mouse Leave: Occurs when the mouse cursor leaves the control’s boundaries
    • Mouse Events with Event Argument of Type MouseEventArgs

      • Mouse Down: Occurs when a mouse button is pressed while the mouse cursor is within a control’s boundaries
      • Mouse Hover: Occurs when the mouse cursor hovers within the control’s boundaries
      • Mouse Move: Occurs when the mouse cursor is moved while in the control’s boundaries
      • Mouse Up: Occurs when a mouse button is released when the cursor is over the control’s boundaries
  • Class MouseEventArgs Properties:

    • Button: Specifies which mouse button was pressed (Left, Right, Middle or none)
    • Clicks: The number of times that the mouse button was clicked
    • X: The x-coordinate within the control where the event occurred
    • Y: The y-coordinate within the control where the event occurred
  • Key events occur when keyboard keys are pressed and released. Such events can be handled for any control that inherits from System.Windows.Forms.Control. There are three key events KeyPress, KeyUp and KeyDown. The KeyPress event occurs when the user presses a key that represents an ASCII character. The specific key can be determined with property KeyChar of the event handler’s KeyPressEventArgs argument. ASCII is a 128-character set of alphanumeric symbols
  • The KeyPress event does not indicate whether modifier keys (e.g., Shift, Alt and Ctrl) were pressed when a key event occurred. If this information is important, the KeyUp or KeyDown events can be used. The KeyEventArgs argument for each of these events contains information about modifier keys. Often, modifier keys are used in conjunction with the mouse to select or highlight information
  • KeyEvents:

  • Key Events with Event Arguments of Type KeyEventArgs

    • Key Down: Generated when a key is initially pressed
    • Key Up: Generated when a key is released
  • Key Event with Event Argument of Type KeyPressEventArgs

    • Key Press: Generated when a key is pressed
  • Class KeyPressEventArgs Properties

    • Key Char: returns the ASCII character for the key pressed
    • Handled: Indicates whether the KeyPress event was handled
  • Class KeyEventArgs Properties

  • Alt: Indicates whether the Alt key was pressed
  • Control: Indicates whether the Ctrl key was pressed
  • Shift: Indicates whether the Shift key was pressed
  • Handled: Indicates whether the event was handled
  • Key Code: Returns the key code for the key as a value from the Keys enumeration. This does not include modifier-key information. It is used to test for a specific key
  • Key Data: Returns the key code for a key combined with modifier information as a Keys value. This property contains all information about the pressed key
  • Key Value: Returns the key code as an int, rather than as a value from the Keys enumeration. This property is used to obtain a numeric representation of the pressed key. The int value is known as a Windows virtual key code
  • Modifiers: Returns a Keys value indicating any pressed modifier keys (Alt, Ctrl and Shift). This property is used to determine modifier-key information only
  • The KeyCode property returns the pressed key, but does not provide any information about modifier keys. Thus, both a capital and a lowercase "a" are represented as the A key

Leave a comment