-
Dec 6th, 2013, 07:29 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] Binded DataGridView in Another Form
Hi
I have a "little" form that has 5 datagridview's, so it's a little full, sometimes some of the dgvs have a lot of rows, so it's a little annoying trying to edit the data.
So I was thinking in someway to solve this situation, and i thought in a new form that pop ups when the user select the datagridview...
Something like, event, save the position, save the size, remove from the original form, opens a new form, add the dgv and set the docking to full... The user edits everything and when closing the form, i just remove the dock, and set the position and the original size...
It's possible? without a large amount of work..
The events and the bindings columns that are in the original form, what will happen? Maybe i should try with a sample project...
Anyway meanwhile i accept suggestions.
Thanks
Rate People That Helped You
Mark Thread Resolved When Resolved
-
Dec 6th, 2013, 07:35 AM
#2
Re: Binded DataGridView in Another Form
I don't know exactly what your form design looks like but might it be easier to use a TabControl so that only one grid is visible at a time? TabControls exist to reduce clutter on forms with lots of controls.
If that's not appropriate then you certainly can do what you suggest. It's a simple matter of Adding the control to the Controls collection of the other form. If it's not docked then you'll have to adjust the Location and Size as required as well. The object will still be assigned to the same member variable in the original form so you can still reference it and handle its events in the same way you always did. When you're done you simply Add it back to the Controls collection of the original form. You should try it with a simple test project first.
-
Dec 6th, 2013, 09:14 AM
#3
Thread Starter
Frenzied Member
Re: Binded DataGridView in Another Form
Thanks JMC
The tabs aren't an option in this form.
But after posting here, i made some tests and everything works fine... It was simpler that i thought.
Here's the sample code:
vb.net Code:
Private Sub DataGridView1_Click(sender As Object, e As System.EventArgs) Handles DataGridView1.Click
If DataGridView1.Parent.Name = "FormEdit" Then Exit Sub
Dim newEdit As New FormEdit
Dim currentDGV As DataGridView = Me.DataGridView1
Dim pos As Point = currentDGV.Location
Dim size As Size = currentDGV.Size
'Remove
Me.Controls.Remove(currentDGV)
'Add
With currentDGV
.Dock = DockStyle.Fill
End With
newEdit.Controls.Add(currentDGV)
newEdit.TopMost = True
newEdit.ShowDialog()
'Restore
newEdit.Controls.Remove(currentDGV)
With currentDGV
.Dock = DockStyle.None
.Size = size
.Location = pos
End With
Me.Controls.Add(currentDGV)
End Sub
Rate People That Helped You
Mark Thread Resolved When Resolved
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|