Results 1 to 8 of 8

Thread: Form.ShowDialog() Hidding problem

  1. #1

    Thread Starter
    Hyperactive Member yousufkhan's Avatar
    Join Date
    Jan 2002
    Location
    India
    Posts
    492

    Form.ShowDialog() Hidding problem

    i have a form called FrmPtnSrch for search employees
    i am call the form in the following manner from other form as modal

    Private Sub BtnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSearch.Click
    Try
    Dim objFrmSrch As New FrmPtnSrch
    objFrmSrch.ShowDialog()
    If intSrchPtnNo <> 0 Then
    txtPtnNo.Text = intSrchPtnNo
    txtPtnNm.Text = StrPtnInfo.PName
    objFrmSrch.Dispose()
    objFrmSrch.Close()
    End If

    Catch ex As Exception
    MsgBox(ex.Message)

    End Try
    end sub
    i have a button on the fromSrch for searching the employee into the table
    and listing them in listview on the FrmSrch form
    it is searching the talble and also listing them in the listvew through a private method
    after listing it is getting hide or desposing off
    i have all ther code i have not writter any were for disposing/closing after listing

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,104

    Re: Form.ShowDialog() Hidding problem

    These two lines probably are not necessary:

    objFrmSrch.Dispose()
    objFrmSrch.Close()

    Aside from that, what is the question?
    My usual boring signature: Nothing

  3. #3
    Addicted Member MetalInquisitor's Avatar
    Join Date
    Sep 2012
    Posts
    143

    Re: Form.ShowDialog() Hidding problem

    Please use code tags for posting code. With 450 posts in this forum you should know very well about that by now.

  4. #4

    Thread Starter
    Hyperactive Member yousufkhan's Avatar
    Join Date
    Jan 2002
    Location
    India
    Posts
    492

    Re: Form.ShowDialog() Hidding problem

    objFrmSrch from is getting displayed but when i click the search button on this form
    the fom is automatically either getting hide or disposing off

  5. #5
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Form.ShowDialog() Hidding problem

    Quote Originally Posted by yousufkhan View Post
    objFrmSrch from is getting displayed but when i click the search button on this form
    the fom is automatically either getting hide or disposing off
    Yup. That's what a dialog's supposed to do. It sets a value or values then returns to the code in the launching form.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  6. #6

    Thread Starter
    Hyperactive Member yousufkhan's Avatar
    Join Date
    Jan 2002
    Location
    India
    Posts
    492

    Re: Form.ShowDialog() Hidding problem

    ofcours it sets the values and then rturn off but its not set the values and getting off
    I have a grid on the dialog form in that grid i am getting some record after click on he search button
    on double click on the grid i like set values and then the dialog for should get off

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Form.ShowDialog() Hidding problem

    Obviously English is not your first language but you might try using a bit of punctuation if your posts. If you were to put in a question mark here and there then it would be easier to determine what question you're actually asking as opposed to just making statements.

    Basically, you're using a dialogue incorrectly. The proper way to use a dialogue is like this:
    vb.net Code:
    1. Using dialogue As New SomeForms
    2.     'Pass initial data into the dialogue if required, e.g.
    3.     dialogue.SomeProperty = someValue
    4.  
    5.     'Display the dialogue.
    6.     If dialogue.ShowDialog() = Windows.Forms.DialogResult.OK Then
    7.         'The user clicked OK.
    8.  
    9.         'Get the final data from the dialogue if required, e.g.
    10.         someOtherValue = dialogue.SomeOtherProperty
    11.  
    12.         'Use final data if required.
    13.     End If
    14. End Using // form is implicitly disposed here
    It's up to you to declare those properties in the dialogue form. The dialogue then doesn't have to know anything about the outside world. It is completely self-contained and can therefore be used anywhere in your project without any reliance of a specific form displaying it or the like. If, for instance, your dialogue is displaying data in a ListView for the user to select, the data from the selected item would be what the dialogue exposes via its public properties.

    In the dialogue, you set the DialogResult to close it. If the user clicks the OK button or otherwise provides affirmative feedback, e.g. double-clicks an item in a list, then you set the DialogResult to OK and the dialogue will close and ShowDialog returns OK. If the user clicks the Cancel button then you set DialogResult to Cancel. If the user clicks the title bar Close button then DialogResult is automatically set to Cancel.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8
    Frenzied Member
    Join Date
    Aug 2009
    Location
    Los Angeles
    Posts
    1,335

    Re: Form.ShowDialog() Hidding problem

    Quote Originally Posted by MetalInquisitor View Post
    Please use code tags for posting code. With 450 posts in this forum you should know very well about that by now.
    and with just 38 posts your learning how to be rude and condesending like some others around here mighty quick. Congratulations

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width