Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Pass a DataGridView's row to another Control's form to add/edit this row

$
0
0

Hello

I want to add and edit a row of datagridview via another form filled with controls dynamically.So I want to pass my row with its differents cells and affect it to another controls' form (added dynamically) .

Here 's my code :

In my form that contain the datagridview I call an instance of my dynamic form:

 Dim fields As New List(Of field)()

   _frmAddEdit = New Frm_Ajout_Modif_dynamique(grille, fields, True, grille.Rows(grille.CurrentRow.Index))

And in my Empty winform that i fill dynamically i have :

 Public Sub New(ByVal drv As DataGridView, ByVal fields As List(Of field), ByVal typeaction As Boolean, ByVal indexrow As Int32, ByVal currentcell As String)
        InitializeComponent()

        Dim top As Integer = 10
        Dim focused As Boolean = False

        Dim selectedRowCount As Int32 = drv.Rows.GetRowCount(DataGridViewElementStates.Selected)
        For Each f As field In fields
            Dim label As New Label()
            label.Text = f.FriendlyName + ":"
            label.Top = top
            label.Left = 5
            label.AutoSize = True
            Me.Controls.Add(label)

            Dim textbox As New TextBox()
            textbox.Tag = f.Field
            Me.Controls.Add(textbox)
'tyeaction= true if the action is edit row 
            If typeaction = True Then 

               'textbox.Text = currentcell
' i dont know what to affect to each textbox 
            Else
                textbox.Text = String.Empty
            End If
        Next


   Public Structure field
        Public Field As String
        Public FriendlyName As String
        Public Value As String
    End Structure

Thanks in advance


Best Regards...Please mark as answer if my post is helpful http://yosr-jemili.blogspot.com




Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>