# Locking the Control

## Content



By default the C1MaskedTextBox control's Value property is editable by users at run time. If you want to lock the control from being edited, you can set the **IsReadOnly** property to **True**.

### In XAML

To lock the **C1MaskedTextBox** control from run-time editing in XAML, add **IsReadOnly="True"** to the **<c1:C1MaskedTextBox>** tag so that it appears similar to the following:

```xml
<c1:C1MaskedTextBox Name="C1MaskedTextBox1" IsReadOnly="True" Height="23" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="120" ></c1:C1MaskedTextBox>
```

### In Code

To lock the **C1MaskedTextBox** control from run-time editing, add the following code to your project:

```vbnet
C1MaskedTextBox1.IsReadOnly = True
```

```csharp
c1MaskedTextBox1.IsReadOnly = true;
```

### At Design Time

To lock the **C1MaskedTextBox** control from run-time editing, complete the following steps:

1.  Click the **C1MaskedTextBox** control once to select it.
2.  Navigate to the **Properties** window, and check the **IsReadOnly** check box.

This will have set the **IsReadOnly** property to **True**.

**Run your project and observe**:

The control is has been locked from editing. Try to click the cursor within the control – notice that the text insertion point (the blinking vertical line) will not appear in the control

![](https://cdn.mescius.io/document-site-files/images/47c7dd3c-b586-44f5-903c-f615f88e343f/images/maskedtextbox/editlock.png)