[RESOLVED][02/03] How to make the focus on activated form only
Hi All ,
I describe clearly within the content of thread, Hope u all understand my problem because my english is bad.
When user open a form within the program, the user only can do action on activated form except others program. Seem like the address book in Windows XP. When u click new contact, u must completely fill up the form before u go back to parent form unless u close it without modification.
Thanks for help me :-) :) :afrog:
Re: [02/03] How to make the focus on activated form only
Use 'ShowDialog' to show your new form, that way focus will remain on the new form until it's closed
Re: [02/03] How to make the focus on activated form only
Thanks your help !!
However, when i used showdialog(), that is not exactly i want because when i activate the childform with showdialog instead of .show, the form do not belong to childform anymore.
:)
Re: [02/03] How to make the focus on activated form only
Are you saying (without actually saying it) that you want this second form to be an MDI child of the first? If so then what you're asking for is not possible. You cannot prevent access to the parent because the child form is actually a child control of the parent. You can prevent access to the other controls without preventing access to the child form too, unless you individually disable each of the other controls.
Re: [02/03] How to make the focus on activated form only
Do something like validate all of the entries.
If not of all of the entries are acceptable, cancel the form closing event and ask the user if they want to abort the entries entirely or just continue with making corrections to the entries.
1 Attachment(s)
Re: [02/03] How to make the focus on activated form only
Thanks ya ...
Code:
If Not IsNothing(frmadd) Then
If Not frmadd.IsDisposed Then
frmadd.BringToFront()
Else
frmadd = New frmAdd
frmadd.lblForm.Text = "Add New Machine Type"
frmadd.lvlItem.Columns.Add("Machine Type", frmadd.lvlItem.Width - 10, HorizontalAlignment.Left)
frmadd.ShowDialog()
frmadd.BringToFront()
End If
Else
frmadd = New frmAdd
frmadd.lblForm.Text = "Add New Machine Type"
frmadd.lvlItem.Columns.Add("Machine Type", frmadd.lvlItem.Width - 10, HorizontalAlignment.Left)
frmadd.ShowDialog()
frmadd.BringToFront()
End If
frmadd.MdiParent = Me.MdiParent
frmadd.Dock = DockStyle.Top
Attachment 59005
The area i mark with circle show that when i open a new Childform.by using .showdialog() it is the way i want, the problem is it will open up a new icon in window panel.However, it would not create a new icon in window panel by using .show() method but it is not the way i want.
hmm~~ Sorry, how to stop the form_closing event ?
Re: [02/03] How to make the focus on activated form only
Just set the form's ShowInTaskbar property to False, which is what you should be doing for all modal dialogues.
Re: [02/03] How to make the focus on activated form only
Opsss ! thanks Jmcilhinney .. U r kind ....hahah ..
Thanks others ppl opinion.. thanks a lot..
I appreciate the help from you all :-)