Home › Forums › WinForms controls › Other WinForms controls › SelectionStart-Property return always 0 in WinTextBox
-
AuthorPosts
-
#18517 |
Hi,
I’m using a “WinTextBox” and need to get the current position of the cursor – within a normal windows TextBox I can use the property “SelectionStart” and I get the current position (if no text is selected) – but if I try the same with the WinTextBox I always get 0 – so I don’t know how to get the information I need – is this a bug in the WinTextBox or is there another property?
Thanks
Oliver
Imported from legacy forums. Posted by Oliver (had 3700 views)
We do not reproduce this here. Using a WinTextBox on a regular form, it always returns the right position.
Do you have a scenario you could provide in details that would help us investigate this further?
Imported from legacy forums. Posted by André (had 324 views)
Sorry, the error occurs only if I try to get the position of the cursor in “TextChanged”-Event – so you should reproduce by creating a form with 2 controls – a WinTextBox and a Label and then use the following code – and that’s the difference between a normal TextBox and a WinTextBox from Xceed – I need the cursor position while the user is editing the WinTextBox…
public Form1()
{
InitializeComponent();
winTextBox1.TextBoxArea.TextChanged += new EventHandler(TextBoxArea_TextChanged);
}void TextBoxArea_TextChanged(object sender, EventArgs e)
{
label1.Text = winTextBox1.TextBoxArea.SelectionStart.ToString();
}
Regards
Oliver
Imported from legacy forums. Posted by Oliver (had 404 views)
We reproduce, and this is due to the fact that we do some custom treatment when editing text.
You will need to use the Application.Idle event to get the right position.
void TextBoxArea_TextChanged( object sender, EventArgs e )
{
Application.Idle += new EventHandler( Application_Idle );
}void Application_Idle( object sender, EventArgs e )
{
Application.Idle -= new EventHandler( Application_Idle );
label1.Text = winTextBox1.TextBoxArea.SelectionStart.ToString();
}Imported from legacy forums. Posted by André (had 445 views)
Thanks – it works [:D]
Imported from legacy forums. Posted by Oliver (had 4446 views)
-
AuthorPosts
- You must be logged in to reply to this topic.