|
-
Mar 13th, 2011, 02:38 PM
#1
Thread Starter
Addicted Member
-
Mar 13th, 2011, 03:07 PM
#2
Re: DataGridViews
try this:
vb Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For Each row As DataGridViewRow In Me.dgv_lista_parteneri_proiect.Rows
If row.IsNewRow Then Exit For
Dim cells As New List(Of Object)(Array.ConvertAll(row.Cells.Cast(Of DataGridViewCell).ToArray, Function(c As DataGridViewCell) If(c.Value IsNot Nothing, c.Value.ToString, "")))
cells.Add(frm_gestionare_proiecte.txt_id_proiect.Text)
frm_gestionare_proiecte.dgv_parteneri.Rows.Add(cells.ToArray)
Next
End Sub
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 13th, 2011, 03:36 PM
#3
Thread Starter
Addicted Member
-
Mar 13th, 2011, 05:13 PM
#4
Re: DataGridViews
in what way is it not working? it worked ok for me when i tested it so there must be circumstances you haven't mentioned. is frm_gestionare_proiecte open when you run the code?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 13th, 2011, 08:31 PM
#5
Re: DataGridViews
In regards to .Paul. solution does the target DataGridView have columns setup prior to attempting to copy rows from the one DataGridView to the other DataGridView?
If not then run the following before running .Paul. code
Code:
frm_gestionare_proiecte.dgv_parteneri.CloneColumns(Me.dgv_lista_parteneri_proiect)
Place this code in a code module
Code:
<Runtime.CompilerServices.Extension()> _
Public Sub CloneColumns(ByVal Self As DataGridView, ByVal CloneFrom As DataGridView)
If Self.ColumnCount = 0 Then
For Each c As DataGridViewColumn In CloneFrom.Columns
Self.Columns.Add(CType(c.Clone, DataGridViewColumn))
Next
End If
End Sub
-
Mar 14th, 2011, 04:46 PM
#6
Thread Starter
Addicted Member
Re: DataGridViews
Sorry for my delay...
Form 1 it's an MDI Child and i think that's the problem...
I've made into Form1 (MDI Child) a "Public Sub" and i think it's more simple like this...
But now the problem is that i can not call this Public Sub (of form1 - mdi child) from the Form2 when i close this form.
Code:
Private Sub btn_iesire_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_iesire.Click
frm_gestionare_proiecte.afisare_parteneri()
Me.Close()
End Sub
Last edited by Alexandru_mbm; Mar 14th, 2011 at 04:51 PM.
I'm still learning VB.NET
Sorry for my bad english
Thanks for your help
-
Mar 15th, 2011, 10:15 AM
#7
Re: DataGridViews
the problem is probably because your mdi child forms are instances
i.e.
vb Code:
dim frm1 as new form1
dim frm2 as new form2
you need to refer to the forms by the instance names
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 15th, 2011, 10:57 AM
#8
Thread Starter
Addicted Member
Re: DataGridViews
MDI Child contains a DataGridView and is opening with this Code from the Parent
Code:
Private Sub ProiecteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProiecteToolStripMenuItem.Click
Dim frm_gestionare_proiecte_frm As New frm_gestionare_proiecte
frm_gestionare_proiecte_frm.MdiParent = Me
frm_gestionare_proiecte_frm.Show()
frm_gestionare_proiecte_frm.WindowState = FormWindowState.Maximized
End Sub
The MDI Child DGV is populating using a "Public Sub afisare_parteneri()".
On this MDI Child (frm_gestionare_proiecte_frm) i have a Link Label that opens a Form (not another MDI Child or Parent) named frm_gestionare_parteneri with this code
Code:
Private Sub lkl_gestionare_parteneri_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles lkl_gestionare_parteneri.LinkClicked
If Me.txt_numarul_cererii_de_depunere_de_proiecte.Text <> String.Empty AndAlso Me.txt_numar_dmi.Text <> String.Empty AndAlso Me.txt_tip_proiect.Text <> String.Empty AndAlso Me.txt_id_proiect.Text <> String.Empty Then
frm_gestionare_parteneri.lbl_numar_proiect.Text = Me.txt_numarul_cererii_de_depunere_de_proiecte.Text & "/" & Me.txt_numar_dmi.Text & "/" & Me.txt_tip_proiect.Text & "/" & Me.txt_id_proiect.Text
frm_gestionare_parteneri.id_proiect = Me.txt_id_proiect.Text
frm_gestionare_parteneri.Show()
Else
MessageBox.Show("Va rugam sa completati numarul contractului in totalitate inainte de definirea activitatilor.", "Avertizare", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Me.txt_numarul_cererii_de_depunere_de_proiecte.Select()
End If
End Sub
The form frm_gestionare_parteneri contanins a DataGridView where i add some values...
The problem is how can i transfer the Values added in the Form frm_gestionare_parteneri DGV to the MDI Child frm_gestionare_proiecte_frm DGV
Because when i call frm_gestionare_proiecte_frm.afisare_parteneri() nothing happends...
I'm still learning VB.NET
Sorry for my bad english
Thanks for your help
-
Mar 15th, 2011, 11:34 AM
#9
Re: DataGridViews
how large is your project? could you upload it?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 15th, 2011, 12:16 PM
#10
Re: DataGridViews
here's an experiment i did, using an mdi form, a child form + an independent form:
vb Code:
Public Class Form1
'this is the mdi form. form2 is the mdichild + form3 is the independent form
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim frm As New Form2
frm.MdiParent = Me
frm.Show()
End Sub
End Class
vb Code:
Public Class Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form3.Show()
Me.AddOwnedForm(Form3)
End Sub
End Class
vb Code:
Public Class Form3
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox(Me.Owner.Name)
End Sub
End Class
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 15th, 2011, 12:21 PM
#11
Thread Starter
Addicted Member
-
Mar 15th, 2011, 12:45 PM
#12
Re: DataGridViews
ok. try this. it's difficult for me to give you a better answer. language barrier
vb Code:
Private Sub lkl_gestionare_parteneri_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles lkl_gestionare_parteneri.LinkClicked
If Me.txt_numarul_cererii_de_depunere_de_proiecte.Text <> String.Empty AndAlso Me.txt_numar_dmi.Text <> String.Empty AndAlso Me.txt_tip_proiect.Text <> String.Empty AndAlso Me.txt_id_proiect.Text <> String.Empty Then
frm_gestionare_parteneri.lbl_numar_proiect.Text = Me.txt_numarul_cererii_de_depunere_de_proiecte.Text & "/" & Me.txt_numar_dmi.Text & "/" & Me.txt_tip_proiect.Text & "/" & Me.txt_id_proiect.Text
frm_gestionare_parteneri.id_proiect = Me.txt_id_proiect.Text
frm_gestionare_parteneri.Show()
Me.AddOwnedForm(frm_gestionare_parteneri)
Else
MessageBox.Show("Va rugam sa completati numarul contractului in totalitate inainte de definirea activitatilor.", "Avertizare", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Me.txt_numarul_cererii_de_depunere_de_proiecte.Select()
End If
End Sub
then to refer to the child frm_gestionare_proiecte form from frm_gestionare_parteneri:
vb Code:
DirectCast(Me.Owner, frm_gestionare_proiecte)
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 15th, 2011, 12:53 PM
#13
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
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
|