Results 1 to 5 of 5

Thread: Datagrid:Current DataRow Copy to NextRow(SOLVED)

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2005
    Posts
    20

    Resolved Datagrid:Current DataRow Copy to NextRow(SOLVED)

    Hi people!I have gotten along in my PDA software development nicely with some help from others.I need some assistance once again.Right now,i have a row of data(in a datagrid) that i wish to copy to a new row right below it.How do i go about it?Pls help if u can.I would appreciate it alot!
    Last edited by Irkiere; Apr 25th, 2005 at 08:08 PM.

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Mar 2005
    Posts
    20

    Re: Datagrid:Current DataRow Copy to NextRow

    Pls help if u can,i have been trawling through the net and can't find any suitable answers!

  3. #3
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: Datagrid:Current DataRow Copy to NextRow:PLS Help!

    firstly is the datagrid based on a database table or are you just adding data to it using datarow method?
    secondly if it is based on table do you want to insert the data to table or just add it to the datagrid
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Mar 2005
    Posts
    20

    Re: Datagrid:Current DataRow Copy to NextRow:PLS Help!

    Thanks for bothering once more strider.Yah,my datagrid is bound to a dataset.Anyway,i have gotten the solution from a friend of mine(Dennis Oh from Singapore).I'm at home now and will post the solution tomorrow morning to share with you guys just in case someone else needs it.Paying it forward !!

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Mar 2005
    Posts
    20

    Here's the solution !

    Private Sub DuplicateRow(ByRef dt As DataTable, ByRef dg As DataGrid, ByVal iIndex As Integer)
    'iIndex is the row to duplicate
    Dim dr As DataRow = dt.NewRow
    Dim iCol As Integer
    For iCol = 0 To 32 'dt.Columns.Count
    With dt.Rows(iIndex)
    dr.Item(iCol) = .Item(iCol)
    End With
    Next
    dt.Rows.InsertAt(dr, iIndex)
    dg.DataSource = dt

    End Sub

    Private Sub MenuNewUnit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MenuNewUnit.Click

    Call DuplicateRow(ds.Tables("MechanismLifeTest"), DataGrid1, ds.Tables("MechanismLifeTest").Rows.Count - 1)

    End Sub

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