Windows Develop Bookmark and Share   
 index > Windows Forms General > TextBox Cursor Position in a Form
 

TextBox Cursor Position in a Form

Hi
I have a Form With TextBox Control , Which will be filled up in form load with somedata.
When i create a Form With Reflection (Activator.CreateInstance(formType, params)), i am not able to control cursor through mouse button....Cursor always set into starting position and will not change even i click in between text.

When i open the same form through "new Form()" i dont have any issue.

Can anyone tell me what could be the reason?


pvm444  Monday, June 15, 2009 8:19 AM
Check if it works when you display that form with ShowDialog() instead of Show(). If it does, you've got a threading problem.

Hans Passant.
nobugz  Monday, June 15, 2009 11:55 AM
Hi pvm444,

I am not sure how did you show the form. Could you please post the whole code of it?

I have done this with the following code and didn't found any problem.
In Form1, click button1 will show Form2.
private void button1_Click(object sender, EventArgs e)
{
Form2 frm = (Form2)Activator.CreateInstance(typeof(Form2));
frm.ShowDialog();
}

In Form2, there is a textbox initialed with some text
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
this.textBox1.Text = "Test text";
}
}

Sincerely,
Kira Qian
Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Wednesday, June 17, 2009 7:09 AM
Check if it works when you display that form with ShowDialog() instead of Show(). If it does, you've got a threading problem.

Hans Passant.
nobugz  Monday, June 15, 2009 11:55 AM
Hi pvm444,

I am not sure how did you show the form. Could you please post the whole code of it?

I have done this with the following code and didn't found any problem.
In Form1, click button1 will show Form2.
private void button1_Click(object sender, EventArgs e)
{
Form2 frm = (Form2)Activator.CreateInstance(typeof(Form2));
frm.ShowDialog();
}

In Form2, there is a textbox initialed with some text
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
this.textBox1.Text = "Test text";
}
}

Sincerely,
Kira Qian
Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Wednesday, June 17, 2009 7:09 AM

You can use google to search for other answers

Custom Search

More Threads

• Different Version of Excel is referred
• Datagrid: Change background color of a single row
• Richtextbox, undo issue.
• cannot reload a listview once I have cleared all entries
• Windows forms user authentication
• Imitating dialog box
• WinForms app not closing right
• How to enable scroll bar property in AxWeb Browser
• C# Grid Drawing Technique help.
• How to write text to another form's textbox