Forms

S

Shane Mergy

Ok I have a program which brings up one form with
mulitple buttons and depending on the button it then
opens a new form... first if at the code of the buttons
click i had Form frmTrans = new Transfer();<---name of
the form class.. and after that line i had
frmTrans.ShowDialog(); well the problem with this was
that the start menu flickered while creating the new form
so i moved the Form frmTrans to a seperate class and made
it a global varible. the problem now is that on the
frmtrans it has a couple text boxes and when you first
show it I want to set the focus to the first of the two
text boxes and I have txtFrom.Focus(); in the forms load
event and I have stepped through the code and it does run
over that line but after the form is displayed the focus
is not set any ideas??? I also tryed to move that
txtFrom.focus() to the gotfocus() and the activated()
proceedures of the form and still no go
 
E

Erdem ALKILIÇGiL

Have you tried to use DoEvents() may be it helps?
C Enright said:
I had similiar issues trying to detect when a form became
visible... (why not an onvisible event or virtual
funciton?)

In my application, I have full screen forms. I went
through a lot of hoopla to make it work correctly as
described below.

Probably the easiest thing for you to do would be to use
a timer that kept track of the form visible state. Each
time it becomes visible and was not visible before you
set the focus to the control. Kind of a lame hack, but
what can you do while you wait for a fix (service pack
1....hopefully)

I ended up creating all my forms at startup. Then I
would show each form non-modally through form.show()...
then after showing the form you can set focus to a
specific control.

However, now you have issues of keeping the main form
from being switched to... You can see the headaches
arise...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top