Click here to Skip to main content
11,409,854 members (60,739 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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:

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 16-Mar-10 23:35pm
Edited 17-Mar-10 3:42am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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 ?
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 10

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Is your textbox readonly? That may be the problem
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

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;
}
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 7

private void button1_Click(object sender, EventArgs e)
{
   Form2 frm2 = new Form2();
   frm2.MdiParent = this;
   frm2.Parent = this.panel1;
   frm2.Show();
   textBox1.Focus()
}
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi,

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

private void Form2_Load(object sender, EventArgs e)
    {
      textBox1.Focus();
    }
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

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 Big Grin | :-D

Thanks.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 8

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.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 9

Perhaps i should use richtextbox control. Smile | :)

thanks for your answers
  Permalink  
v2

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 270
1 OriginalGriff 255
2 Maciej Los 138
3 Andy Lanng 115
4 Sascha Lefévre 85
0 Sergey Alexandrovich Kryukov 8,731
1 OriginalGriff 6,895
2 Maciej Los 3,332
3 Abhinav S 3,248
4 Peter Leow 3,059


Advertise | Privacy | Mobile
Web03 | 2.8.150414.5 | Last Updated 19 Mar 2010
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100