且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何打开窗体

更新时间:2023-12-06 15:35:40

看看这个: Form.ShowDialog [ ^ ]。阅读完毕后,您应该能够完成此任务。


要在主应用程序中显示子表单,您必须先在应用程序中定义子表单,然后根据您的方法调用以下方法需要。

例如:此示例将您的子表单显示为模型对话框,阻止用户访问主表单,除非他/她关闭子表单。

  private   void  child1Button_Click( object  sender,EventArgs e)
{
Form2 testDialog = new Form2();

// 将testDialog显示为模态对话框并确定DialogResult = OK。
if (testDialog.ShowDialog( this )== DialogResult.OK)
{
// 执行成功操作
}
else
{
// 子表单取消
}
testDialog.Dispose();

}





将您的孩子显示为无模式对话框。

  private   void  child1Button_Click( object  sender,EventArgs e)
{
Form2 testDialog = new Form2();
testDialog.Show();
}


Quote:

hi bikramjeet,

我遇到了你的问题。我在创建许可应用程序时也遇到了同样的问题。幸运的是我看到了你的问题。



我认为以下代码(vb.net)将解决你的问题



 Dim frm As new frmLicense 
Private Sub MainForm_Activated(ByVal sender As Object,ByVal e As System.EventArgs)Handles Me.Activated
如果不是frm.IsDisposed那么
frm.Focus()
结束如果
结束Sub

Private Sub MainForm_Load(ByVal sender As Object,ByVal e As System.EventArgs )Handles Me.Load
frm.TopMost = True
frm.Show()
End Sub





我写了简单的代码。 frmlicense是您的许可证激活弹出窗体。如果你愿意,我建议让它成为单身人士。你可以使用任何转换器来获取c#代码。不要以为它需要。



这肯定会解决你的问题。如果你觉得这个合适,那就接受为解决方案。所以对其他人也有帮助。


Hello friend,

I need a help in ado.net what i want to do i did know how can i do that.

http://oi50.tinypic.com/m7fie.jpg

Or

http://i48.tinypic.com/avhjti.png[^]

I have window application and i want to open one form like example image.
What I want to do now when user complete installation of my application on user system
the user can click on icon for run the application. There will be come Main Window form where user can able to tack access of all functions but when Main form will come out then i also want a Activation Form Open upon a Main from this form never hid close
till then user never Activate the Application with enter the code.
so how can i open Activation Form Open upon a Main from.

hope you my help me in it
Thanks

Have a look at this: Form.ShowDialog[^]. You should be able to accomplish this after reading that.


To display a child forms from your main application you have to first define your child forms in your application and call the following methods based on your need.
eg: This examples displays your child form as Model dialog which blocks the user to access the main form unless he/she close the child form.
private void child1Button_Click(object sender, EventArgs e)
{
  Form2 testDialog = new Form2();

  // Show testDialog as a modal dialog and determine if DialogResult = OK.
  if (testDialog.ShowDialog(this) == DialogResult.OK)
  {
     //do success operation
  }
  else
  {
     // Child form is cancelled
  }
  testDialog.Dispose();

}



To display your child as Modeless dialog.

private void child1Button_Click(object sender, EventArgs e)
 {
   Form2 testDialog = new Form2();
   testDialog.Show();
 }


Quote:

hi bikramjeet,
I got your problem. I also faced same problem while creating licensed application.Luckily i saw your problem.

I think following code (vb.net) will solve your problem

Dim frm As New frmLicense
    Private Sub MainForm_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
        If Not frm.IsDisposed Then
            frm.Focus()
        End If
    End Sub

    Private Sub MainForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        frm.TopMost = True
        frm.Show()
    End Sub



I have written simple code. frmlicense is your license activation popup form. I suggest make it singleton if u want. U can use any converter to get c# code. don''t think its needed.

This will definitely solve your problem. If u find this suitable,accept as solution.So it will be helpful to other also.