ICreate.Controls.Bars Send comments on this topic.
Checked Property
See Also  Example
ICreate.Controls.Bars Namespace > CommandItem Class : Checked Property






Gets or sets the value indicating if the CommandItem is in the Checked state.

Syntax

Visual Basic (Declaration) 
Public Property Checked As Boolean
Visual Basic (Usage)Copy Code
Dim instance As CommandItem
Dim value As Boolean
 
instance.Checked = value
 
value = instance.Checked
C# 
public bool Checked {get; set;}
Delphi 
public read-write property Checked: Boolean; 
JScript 
public function get,set Checked : boolean
Managed Extensions for C++ 
public: __property bool get_Checked();
public: __property void set_Checked( 
   bool value
);
C++/CLI 
public:
property bool Checked {
   bool get();
   void set (bool value);
}

Return Value

A System.Boolean value this property determines if the CommandItem is in the Checked state. If true then the CommandItem is Checked; otherwise it is false and the CommandItem is not checked.

Example

This example shows how to use the Checked property to toggel the checked state of the CommandItem.

Note that the CheckOnClick property can be used to specify that the Checked state of the ComandItem should be toggled automatically.

To run this example create a WinForm application with a Form as indicated below, compile and execute the example application.

C#Copy Code
using System; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Windows.Forms; 
 
namespace ExamplesCSharp 

    public partial class CheckedPropertyExample : Form 
    { 
        public CheckedPropertyExample() 
        { 
            InitializeComponent(); 
 
            commandButton.PressedForeColor = Color.Black; 
            commandButton.PressedBackColor = Color.Gray; 
            commandButton.CheckedForeColor = Color.White; 
            commandButton.CheckedBackColor = Color.Blue; 
        } 
 
        private void commandButton_Click(object sender, EventArgs e) 
        { 
            commandButton.Checked = !commandButton.Checked; 
        } 
    } 
}
Visual BasicCopy Code
Public Class CheckedPropertyExample

    Private Sub CommandButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CommandButton.Click
        CommandButton.Checked = Not CommandButton.Checked
    End Sub

    Public Sub New()

        InitializeComponent()

        CommandButton.PressedForeColor = Color.Black
        CommandButton.PressedBackColor = Color.Gray
        CommandButton.CheckedForeColor = Color.White
        CommandButton.CheckedBackColor = Color.Blue

    End Sub

    Protected Overrides Sub Finalize()
        MyBase.Finalize()
    End Sub
End Class

Remarks

When a CommandItem is Checked it is drawn in the depressed state, the colour of the text is CheckedForColor and the background colour is CheckedBackColor.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also