Posts Tagged ‘Alignment’

Bullet Point Indentation on TextControl

Thursday, March 5th, 2009

I use TextControl .NET for a lot of the programs that I write – it is a great word processor component and works well for document based reporting as well.  However, there are a few niggling little bugs that annoy me.  One of them is bullet point indentation.  

I discussed this problem with the technical support people at TextControl and they said that I would have to write some code to catch the Changed event.  

I initially thought that this was a problem with the bullet point indentation itself, and then I noticed that if I added bullet points and removed them, the paragraph jumped back to 0 (default indentation is usually 500).  

After a bit of playing about, I discovered that I needed to change the selection’s paragraph format properties for left indent and hanging indent as follows: -

    Private Sub tcEditor_Changed(ByVal sender As Object, ByVal e As System.EventArgs) Handles tcEditor.Changed

        If tcEditor.Selection.ParagraphFormat.LeftIndent < 500 AndAlso tcEditor.Tables.GetItem() Is Nothing Then            tcEditor.Selection.ParagraphFormat.LeftIndent = tcEditor.Selection.ParagraphFormat.HangingIndent + 500
        End If
    End Sub

This might look a little odd, but in order to set the left indent to the correct value, it needs to be 500 greater than the hanging indent in order to get the correct behaviour