Enabled Property

Microsoft Speech Platform SDK 11

Collapse imageExpand ImageCopy imageCopyHover image

Gets or sets a value that controls whether a Grammar can be used by a recognition engine to perform recognition.

Namespace:  Microsoft.Speech.Recognition
Assembly:  Microsoft.Speech (in Microsoft.Speech.dll)

Syntax

Visual Basic (Declaration)
Public Property Enabled As Boolean
	Get
	Set
Visual Basic (Usage)
Dim instance As Grammar
Dim value As Boolean

value = instance.Enabled

instance.Enabled = value
C#
public bool Enabled { get; set; }

Property Value

Type: System..::..Boolean

The Enabled property returns true if a speech recognizer can perform recognition using the speech recognition grammar; otherwise the property returns false. The default is true.

Remarks

An instance of Grammar may be enabled or disabled independently of being loaded by a SpeechRecognitionEngine object.

Examples

The following example shows a check box handler for a TreeView. When the box is checked, the grammar is enabled.

C# Copy imageCopy Code
private void _grammarTreeView_AfterCheck(object sender, TreeViewEventArgs eventArgs) 
{
  if (eventArgs.Action != TreeViewAction.Unknown) 
  { // Avoid recursion due to handlers
    if (eventArgs.Node.Parent == null) 
    {
      Grammar grammar = ((Grammar)eventArgs.Node.Tag);
      grammar.Enabled = eventArgs.Node.Checked;
      PropagateCheckStatus(eventArgs.Node);
    } 
    else 
    {
      PropagateCheckStatus(eventArgs.Node.Parent);
    }
  }
}

See Also