We received an interesting feature request in our support department: The ability to open the tab dialog when a user clicks a tab position in the TXTextControl.RulerBar class TX Text Control .NET for Windows Forms
TXTextControl Namespace
RulerBar Class
The RulerBar class represents a Windows Forms tool bar which can be used to show or to set indents, margins and tabs of a Windows Forms TextControl.
.

User input drives our development and we listen to all user requests and requirements. Such requests are collected and considered for future releases of our products. But most features can be already implemented based on the flexible API and our support services help with these requirements. We help with code snippets and tailored sample applications for all your requests.

Our technical support is part of every subscription license and you can also upgrade your non-subscription licenses to benefit from this service.

If you would like to learn more about the subscription services, feel free to contact us.

In order to trap the double-click event in the RulerBar, the position needs to be calculated. In the MouseDoubleClick event, the position related to the document is calculated based on the scroll location and zoom factor.

Then the click location is compared to all tab positions at the current input position. If a tab position matches the click position within a range of 100 twips, the dialog is opened.

private void rulerBar1_MouseDoubleClick(object sender, MouseEventArgs e)
{
// calculate zoom factor
float fZoomFactor = (float)textControl1.ZoomFactor / 100;
// get the click location in the ruler bar
int iClickLocation = (int)((e.X * iDpiX) + (textControl1.ScrollLocation.X * fZoomFactor));
// loop through all tab positions
foreach (int tabPosition in textControl1.Paragraphs.GetItem(
textControl1.Selection.Start).Format.TabPositions)
{
// retrieve the exact location including zoom factor
int iTabLocation = (int)((tabPosition +
textControl1.Sections.GetItem().Format.PageMargins.Left) * fZoomFactor);
// if click location matches tab position
// open the tab dialog
if (iClickLocation >= iTabLocation - 50 && iClickLocation <= iTabLocation + 50)
{
textControl1.TabDialog(); // open dialog
break;
}
}
}
view raw test.cs hosted with ❤ by GitHub

You can download the full sample from our GitHub repository.