# InputFormat.StyleName Property

> Gets or sets the formatting style name at the current input position. If text is selected, the property specifies the style of the whole selected text.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Reference
- **Kind:** Property
- **Introduced:** 16.0
- **Namespace:** `TXTextControl`
- **Package:** `TXTextControl.TextControl.WinForms.SDK` (assembly `TXTextControl.dll`, from the private NuGet feed or Text Control Offline Packages)
- **.NET Framework:** reference `TXTextControl.dll` from the setup
- **Path:** TX Text Control .NET for Windows Forms > Reference > TXTextControl > InputFormat.StyleName Property
- **720 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/inputformat/stylename-property/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/inputformat/stylename-property/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/inputformat/stylename-property/llms-full.txt

---

### Description

Gets or sets the formatting style name at the current input position. If text is selected, the property specifies the style of the whole selected text.

### Syntax

```csharp
public string StyleName { get; set; }
```

```vbnet
Public Property StyleName As String
```

### Examples

The following XAML example shows how to bind the StyleName property to a combo box which contains all style names returned by the [StyleNames](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/inputformat/stylenames-property/llms-full.txt) property.

```plaintext
<ComboBox
    Width="200"
    IsEditable="True"
    IsReadOnly="True"
    Text="{Binding ElementName=textControl1, Path=InputFormat.StyleName}"
    ItemsSource="{Binding ElementName=textControl1, Path=InputFormat.StyleNames}" />
```

The following example changes the formatting applied to text entered at the end of a document by using `InputFormat.StyleName`.

```csharp
textControl.Text = "Project summary";
textControl.InputPosition = new InputPosition(textControl.Text.Length);
InputFormat inputFormat = textControl.InputFormat;

inputFormat.StyleName = "CustomerName";
if (!string.IsNullOrWhiteSpace(inputFormat.StyleName))
{
    Console.WriteLine($"Style Name: {inputFormat.StyleName}");
}
```

```vbnet
textControl.Text = "Project summary"
textControl.InputPosition = New InputPosition(textControl.Text.Length)
Dim inputFormat As InputFormat = textControl.InputFormat

inputFormat.StyleName = "CustomerName"
If Not String.IsNullOrWhiteSpace(inputFormat.StyleName) Then
    Console.WriteLine($"Style Name: {inputFormat.StyleName}")
End If
```

### Remarks

The property returns null when the text selection contains multiple characters with different styles.

---

## Nearby

- **Previous:** [InputFormat.StructureLevel Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/inputformat/structurelevel-property/llms-full.txt)
- **Next:** [InputFormat.StyleNames Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/inputformat/stylenames-property/llms-full.txt)
