Click here to Skip to main content
15,879,072 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all!

I have problem with mdiform.
Example:
My project have two form (Form1 and Form2)
- form1 have a button and a panel.
- form2 have a textbox
when I click button on form1 then show form2 in panel of form1,
now i input data into textbox but i can not use mouse to jump cursor in textbox.

code following:

C#
private void button1_Click(object sender, EventArgs e)
{
   Form2 frm2 = new Form2();
   frm2.MdiParent = this;
   frm2.Parent = this.panel1;
   frm2.Show();
}


Please, help me.
thanks!
Posted
Updated 17-Mar-10 2:42am
v2

This code occurs within the mouse click. How do you expect this code to do anything with a textbox, when it's creating a new form and showing it, nothing more ?
 
Share this answer
 
This is insanity. The textbox obviously has the focus if you are typing in to it. Your code snippet continues to be useless, and a source of confusion to people. There's no reason for this not to work, and setting the focus on the textbox is not going to help, it has the focus already.

It would be easier to answer you if you'd edit your post instead of pushing 'answer' to post something that is plainly NOT an answer.
 
Share this answer
 
Is your textbox readonly? That may be the problem
 
Share this answer
 
Hi!!!


This Code Will Help you
private void button1_Click(object sender, EventArgs e)
{
Form2 frm2 = new Form2();
frm2.MdiParent = this;
frm2.Parent = this.panel1;
frm2.Show();
textbox1.focus=true;
}
 
Share this answer
 
v2
C#
private void button1_Click(object sender, EventArgs e)
{
   Form2 frm2 = new Form2();
   frm2.MdiParent = this;
   frm2.Parent = this.panel1;
   frm2.Show();
   textBox1.Focus()
}
 
Share this answer
 
You will have to remove the caption bar from the form. That's best done by adding this line to your code:

newReportForm.FormBorderStyle = Windows.Forms.FormBorderStyle.None
 
Share this answer
 
Hi,

Call the textbox's focus on load event of Form2 and try again (refer the following code)

C#
private void Form2_Load(object sender, EventArgs e)
    {
      textBox1.Focus();
    }
 
Share this answer
 
Hi, Vineethpj
Thanks for your answer.

Problem is i still input data onto textbox normally, but i can not use mouse to set cursor at a character i want.
example:
i enter on textbox "abcdef ghk", now i want to use mouse to set cursor at "a" character position.

You try create a simple project with two forms
- Form1 have a button and a panel control
- Form2 have a textbox control
On form1 you create button_click event (the following code)

private void button1_Click(object sender, EventArgs e)
{
Form2 frm2 = new Form2();
frm2.MdiParent = this;
frm2.Parent = this.panel1;
frm2.Show();
}

Thanks,regard.
 
Share this answer
 
Hi, Tim Yen.

I can enter data on textbox. It mean Textbox.Readonly = false.
Ploblem is i put form2 in panel of form1.
Because my main project is the same design :-D

Thanks.
 
Share this answer
 
v2
Hi,everybody!

Perhaps everybody don't understand what i say,hixhixhix

everybody download project demo.

http://www.mediafire.com/file/yymnkwdjy4d/Test.rar[^]

Run it,click button to show form2 and enter data on textbox, after use mouse click at begin character on textbox.

Thanks, regard.
 
Share this answer
 
v2
Perhaps i should use richtextbox control. :)

thanks for your answers
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900