Grammar.Enabled Property

Gets or sets a value controlling whether a Grammar can be used by a recognition engine.

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



Property Value

Property is a bool value which is set to true if an instance of Grammar is enabled and ready to process input, and false it the instance is not available for input processing.


An instance of Grammar may be enabled or disabled independently of being loaded by a recognition engine (SpeechRecognizer or SpeechRecognitionEngine);


The example below show a check box handler for a Windows.Forms.TreeView. When the box is checked, the grammar is enabled.

private void _grammarTreeView_AfterCheck(object sender, TreeViewEventArgs eventArgs) {
  if (eventArgs.Action != TreeViewAction.Unknown) { // Avoid recurse due to hanlders
    if (eventArgs.Node.Parent == null) {
      Grammar grammar=((Grammar)eventArgs.Node.Tag);
      grammar.Enabled = eventArgs.Node.Checked;
    } else {

Thread Safety

All public static (Shared in Visual Basic) members of this type are thread-safe. Instance members are not guaranteed to be thread-safe.


Development Platforms

Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003, Windows Vista Ultimate Edition, Windows Vista Business Edition, Windows Vista Enterprise Edition

Target Platforms

See Also


Grammar Class
Grammar Members
Microsoft.Speech.Recognition Namespace
Grammar Class

Other Resources

Speech Recognition Grammar Specification