Double Click SFDatagrid - Opens Child Form

Hi Team,

I have form1 which is my parent form, Form2 which as my sfdatagrid which is a child form of form1  and form 3 which is a blank form that is a child of form1 also. 
I'm trying to double click on sfdatagrid and that then opens form3 over form2, however when i double click on sfdatagrid nothing happens. 

Public Class Form2
    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'BELGRADEDataSet.UDEF_STOCK_BY_LOCATION_LEEDS' table. You can move, or remove it, as needed.
        Me.UDEF_STOCK_BY_LOCATION_LEEDSTableAdapter.Fill(Me.BELGRADEDataSet.UDEF_STOCK_BY_LOCATION_LEEDS)
    End Sub
    Private Sub SFDataGrid_CellDoubleClick(ByVal sender As Object, ByVal e As Syncfusion.WinForms.DataGrid.Events.CellClickEventArgs)
        Form3.Show()
        Form3.MdiParent = Form1
    End Sub
End Class

Thanks in advance for your help.

7 Replies

AA Arulraj A Syncfusion Team September 19, 2018 06:41 AM UTC

Hi Paul, 
 
Thanks for using Syncfusion product. 
 
You can achieve the requirement by using the Form’s MdiParent, BringToFront() and SfDataGrid’s CellDoubleClick event. Please find the following code snipped and the sample link for details. 
 
‘Main Form 
Private Sub MainForm_Load(sender As Object, e As System.EventArgs) Handles MyBase.Load 
        Dim form1 = New Form1() 
        form1.TopLevel = false 
        form1.MdiParent = Me 
        form1.Show() 
    End Sub 
 
‘Form1 which has SfDataGrid 
Private Sub sfDataGrid_CellDoubleClick(ByVal sender As Object, ByVal e As CellClickEventArgs) 
              e.Cancel = True 
              Dim form = New Form() 
             form.TopLevel = false 
             me.Controls.Add(form) 
             form.BringToFront() 
             form.Show() 
              End Sub 
 

Please let us know if you need any further assistance on this. 

Arulraj A 



PA Paul September 19, 2018 12:48 PM UTC

Hi Team, 

I've tried the below as suggest. however when i double click on the SFdatagrid form3 doesnt open. I've added the code as it appears on each form.

Any help would be greatly appreciated.

Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim form2 = New Form2()
        form2.TopLevel = False
        form2.MdiParent = Me
        form2.Show()
    End Sub

Form2
    Private Sub SFDataGrid_CellDoubleClick(ByVal sender As Object, ByVal e As Syncfusion.WinForms.DataGrid.Events.CellClickEventArgs)
        e.Cancel = True
        Dim form3 = New Form3()
        form3.TopLevel = False
        Me.Controls.Add(form3)
        form3.BringToFront()
        form3.Show()
    End Sub

Form3
    Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub






AA Arulraj A Syncfusion Team September 20, 2018 09:17 AM UTC

Hi Paul, 

Thanks for your update.  

We have created a simple sample with the code provided by you in your very first update to replicate your scenario and it is working properly in our end. Please have a look at the sample from the following location and let us know if we missed any customization. If still the issue exists, please confirm the current Essential Studio version you are using. It will be helpful for us to find the exact cause for the issue and resolve it. 


Arulraj A 



PA Paul September 20, 2018 11:08 AM UTC

Hi Team,

Thanks for the sample. I'm just struggling how to change it to look at my SQL View instead of your data set.

Any assistance on how i do this would be appreciated.

Cheers


AA Arulraj A Syncfusion Team September 20, 2018 12:25 PM UTC

Hi Paul, 

Thanks for your update.  

Please find the sample using SQL from the following location and let us know if this helps.  

Arulraj A 



PA Paul September 20, 2018 01:29 PM UTC

Thanks that worked great!!  

One issue with Form3, once it's opened you can still go back to to form2 without closing form3. Is it possible you have to close form3 to get back to form2? 

Cheers


AA Arulraj A Syncfusion Team September 21, 2018 05:49 AM UTC

Hi Paul,  

Thanks for your update. 

By default, Form doesn’t allow to open an MDI child as a modal form. However your requirement can be achieved by a workaround of disabling all the other MDI children of the Form1 (parent form) within the OnShown method and again enabling them in the OnClosed method of Form3. 

Please refer to the following code to be included in Form3 and sample from the given location. 

Code Example: 

Protected Overrides Sub OnShown(ByVal e As EventArgs) 
    Dim parent = TryCast(Me.MdiParent, Form) 
 
    If parent IsNot Nothing Then 
        For Each child In parent.MdiChildren 
            If child IsNot Me Then 
                child.Enabled = False 
            End If 
        Next child 
    End If 
 
    MyBase.OnShown(e) 
End Sub 
 
Protected Overrides Sub OnClosed(ByVal e As EventArgs) 
    Dim parent = TryCast(Me.MdiParent, Form) 
 
    If parent IsNot Nothing Then 
        For Each child In parent.MdiChildren 
            If child IsNot Me Then 
                child.Enabled = True 
            End If 
        Next child 
    End If 
 
    MyBase.OnClosed(e) 
End Sub 


Arulraj A 


Loader.
Up arrow icon