Hidden data addition

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Eric Dreksler

    Hidden data addition

    Hello,

    I was wondering if anyone could tell me a good way to add data to a datagrid
    (or it's dataset) when the user edits/adds a record in a datagrid.

    Basically, I want to be able to add a username / timestamp to a record, I'm
    sure there are plenty of ways to do this, but I'm sure it's been done before
    and was wondering if anyone had any good proceedures they use, since I've
    started using datagrids more frequently.

    Thanks In Advance,
    Eric Dreksler


  • Cor Ligthert

    #2
    Re: Hidden data addition

    Hi Eric,

    When we are talking about data processing than the starndaard datasource of
    a datagrid is/are datatable(s). (Can by using the dataview however it stays
    the datatable)

    You can add as much datacolumns to a datatable as you wish however than you
    should use the datagridtablest yles to show the proper colums in the
    datagrid.

    You can as well declare the datatable withevents which means that you can by
    instance use the datatable row changed event to do updating as you say.

    Just some idea's

    Cor
    [color=blue]
    >
    > I was wondering if anyone could tell me a good way to add data to a[/color]
    datagrid[color=blue]
    > (or it's dataset) when the user edits/adds a record in a datagrid.
    >
    > Basically, I want to be able to add a username / timestamp to a record,[/color]
    I'm[color=blue]
    > sure there are plenty of ways to do this, but I'm sure it's been done[/color]
    before[color=blue]
    > and was wondering if anyone had any good proceedures they use, since I've
    > started using datagrids more frequently.
    >
    > Thanks In Advance,
    > Eric Dreksler
    >
    >[/color]


    Comment

    • Eric Dreksler

      #3
      Re: Hidden data addition

      All right,
      I have my datagrid setup (and I'm using a DataTable), however I can't seem
      to figure out how to get the RowChanging and RowChanged events to work for
      me.

      On RowChanging, it won't let me change a row marked for updating. And on
      RowChanged, if I try to update the e.Row arguement it sends me into a loop
      (continually calling the RowChanged Event), until it just crashes out.


      "Cor Ligthert" <notfirstname@p lanet.nl> wrote in message
      news:e7k4x6iTEH A.3528@TK2MSFTN GP12.phx.gbl...[color=blue]
      > Hi Eric,
      >
      > When we are talking about data processing than the starndaard datasource[/color]
      of[color=blue]
      > a datagrid is/are datatable(s). (Can by using the dataview however it[/color]
      stays[color=blue]
      > the datatable)
      >
      > You can add as much datacolumns to a datatable as you wish however than[/color]
      you[color=blue]
      > should use the datagridtablest yles to show the proper colums in the
      > datagrid.
      >
      > You can as well declare the datatable withevents which means that you can[/color]
      by[color=blue]
      > instance use the datatable row changed event to do updating as you say.
      >
      > Just some idea's
      >
      > Cor
      >[color=green]
      > >
      > > I was wondering if anyone could tell me a good way to add data to a[/color]
      > datagrid[color=green]
      > > (or it's dataset) when the user edits/adds a record in a datagrid.
      > >
      > > Basically, I want to be able to add a username / timestamp to a record,[/color]
      > I'm[color=green]
      > > sure there are plenty of ways to do this, but I'm sure it's been done[/color]
      > before[color=green]
      > > and was wondering if anyone had any good proceedures they use, since[/color][/color]
      I've[color=blue][color=green]
      > > started using datagrids more frequently.
      > >
      > > Thanks In Advance,
      > > Eric Dreksler
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Cor Ligthert

        #4
        Re: Hidden data addition

        Hi Eric,

        I thought something as this (however I am not very sure, the endedit did
        throw an error, but it was not needed for this sample, it is more said in
        this newsgroup, that this event is not the best part of the framework)

        However, I hope it helps?

        Cor

        \\\
        Dim bool As Boolean
        Private Sub Form1_Load(ByVa l sender As Object, _
        ByVal e As System.EventArg s) Handles MyBase.Load
        'to make the sample table
        dt.Columns.Add( "col1")
        dt.Columns.Add( "col2")
        For i As Integer = 0 To 5
        Dim dr As DataRow = dt.NewRow
        dr(0) = i.ToString
        dt.Rows.Add(dr)
        Next
        DataGrid1.DataS ource = dt
        bool = True
        End Sub

        Private Sub dt_RowChanged(B yVal sender As Object, _
        ByVal e As System.Data.Dat aRowChangeEvent Args) _
        Handles dt.RowChanged
        e.Row.BeginEdit ()
        If bool Then
        e.Row(1) = e.Row(0)
        End If
        End Sub
        ///


        Comment

        Working...