Fill datatable

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

    #1

    Fill datatable

    hi,

    How can I fill some DataTable by clicking in cells of a DataGrid control?

    NOTE: I don't want to select a entire row, ok? I must select only one or
    more cells...

    I have a DataGrid that have some data that I must select what I want and
    then by clicking in a Button it will create some records in DataBase.
    So I want to construct a DataTable by clicking in DataGrid, for then allows
    me to cover this DataTable and create the records in DB.


    --
    Programming ASP.NET with VB.NET
    Thank's (if you try to help me)
    Hope this help you (if I try to help you)
    ruca


  • Chris

    #2
    Re: Fill datatable

    ruca wrote:[color=blue]
    > hi,
    >
    > How can I fill some DataTable by clicking in cells of a DataGrid control?
    >
    > NOTE: I don't want to select a entire row, ok? I must select only one or
    > more cells...
    >
    > I have a DataGrid that have some data that I must select what I want and
    > then by clicking in a Button it will create some records in DataBase.
    > So I want to construct a DataTable by clicking in DataGrid, for then allows
    > me to cover this DataTable and create the records in DB.
    >
    >[/color]


    The example below is used to make it so no column can be selected but
    selects the entire row instead. Add it to your datagridtablest yle.
    Then you will need to capture the click event in the datagrid (probably
    should just be capture the row change instead) and do a datagridhittest
    on it.

    Hope that helps
    Chris

    FullDisclosure: This was used from some website... No idea who
    Public Class DataGridNoActiv eCellColumn
    Inherits DataGridTextBox Column

    Private SelectedRow As Integer = -1
    Protected Overloads Overrides Sub Edit(ByVal source As
    System.Windows. Forms.CurrencyM anager, ByVal rowNum As Integer, ByVal
    bounds As System.Drawing. Rectangle, ByVal [readOnly] As Boolean, ByVal
    instantText As String, ByVal cellIsVisible As Boolean)

    'make sure previous selection is valid
    If SelectedRow > -1 And SelectedRow < source.List.Cou nt + 1 Then
    Me.DataGridTabl eStyle.DataGrid .UnSelect(Selec tedRow)
    End If
    SelectedRow = rowNum
    Me.DataGridTabl eStyle.DataGrid .Select(Selecte dRow)
    End Sub

    End Class

    Comment

    • ruca

      #3
      Re: Fill datatable

      hi,

      I think that you're talking about Windows Forms, and I'm talk about Web
      Forms. It's a quiet different...

      Thank's anyway


      --
      Programming ASP.NET with VB.NET
      Thank's (if you try to help me)
      Hope this help you (if I try to help you)
      ruca

      "Chris" <no@spam.com> escreveu na mensagem
      news:OQC4I7DyFH A.448@TK2MSFTNG P11.phx.gbl...[color=blue]
      > ruca wrote:[color=green]
      >> hi,
      >>
      >> How can I fill some DataTable by clicking in cells of a DataGrid control?
      >>
      >> NOTE: I don't want to select a entire row, ok? I must select only one or
      >> more cells...
      >>
      >> I have a DataGrid that have some data that I must select what I want and
      >> then by clicking in a Button it will create some records in DataBase.
      >> So I want to construct a DataTable by clicking in DataGrid, for then
      >> allows me to cover this DataTable and create the records in DB.
      >>
      >>[/color]
      >
      >
      > The example below is used to make it so no column can be selected but
      > selects the entire row instead. Add it to your datagridtablest yle. Then
      > you will need to capture the click event in the datagrid (probably should
      > just be capture the row change instead) and do a datagridhittest on it.
      >
      > Hope that helps
      > Chris
      >
      > FullDisclosure: This was used from some website... No idea who
      > Public Class DataGridNoActiv eCellColumn
      > Inherits DataGridTextBox Column
      >
      > Private SelectedRow As Integer = -1
      > Protected Overloads Overrides Sub Edit(ByVal source As
      > System.Windows. Forms.CurrencyM anager, ByVal rowNum As Integer, ByVal
      > bounds As System.Drawing. Rectangle, ByVal [readOnly] As Boolean, ByVal
      > instantText As String, ByVal cellIsVisible As Boolean)
      >
      > 'make sure previous selection is valid
      > If SelectedRow > -1 And SelectedRow < source.List.Cou nt + 1 Then
      > Me.DataGridTabl eStyle.DataGrid .UnSelect(Selec tedRow)
      > End If
      > SelectedRow = rowNum
      > Me.DataGridTabl eStyle.DataGrid .Select(Selecte dRow)
      > End Sub
      >
      > End Class
      >[/color]


      Comment

      • ruca

        #4
        Re: Fill datatable

        Hi,

        Someone have any idea how can I do this?!?!?!?!?!? !


        --
        Programming ASP.NET with VB.NET
        Thank's (if you try to help me)
        Hope this help you (if I try to help you)
        ruca

        "ruca" <ruuca@iol.pt > escreveu na mensagem
        news:%23Zwr7rDy FHA.3720@TK2MSF TNGP11.phx.gbl. ..[color=blue]
        > hi,
        >
        > How can I fill some DataTable by clicking in cells of a DataGrid control?
        >
        > NOTE: I don't want to select a entire row, ok? I must select only one or
        > more cells...
        >
        > I have a DataGrid that have some data that I must select what I want and
        > then by clicking in a Button it will create some records in DataBase.
        > So I want to construct a DataTable by clicking in DataGrid, for then
        > allows me to cover this DataTable and create the records in DB.
        >
        >
        > --
        > Programming ASP.NET with VB.NET
        > Thank's (if you try to help me)
        > Hope this help you (if I try to help you)
        > ruca
        >[/color]


        Comment

        Working...