how do I link a datagridview to a dataset?

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

    how do I link a datagridview to a dataset?

    In VB 2008 how do I link the datagridview to a dataset?

    mydataadapter.f ill(myds, "test")
    datagridview1.? ???????

    When I was using 2005 I used the datagrid and it was done like:

    mydataadapter.f ill(myds, "test")
    datagrid1.DataG rid1.SetDataBin ding(ds, tableName)

    but in 2008 with the datagridview setdatabinding doesn't exist.
  • Jack Jackson

    #2
    Re: how do I link a datagridview to a dataset?

    On Thu, 19 Jun 2008 14:59:45 -0400, cj <cj@nospam.nosp amwrote:
    >In VB 2008 how do I link the datagridview to a dataset?
    >
    >mydataadapter. fill(myds, "test")
    >datagridview1. ????????
    >
    >When I was using 2005 I used the datagrid and it was done like:
    >
    >mydataadapter. fill(myds, "test")
    >datagrid1.Data Grid1.SetDataBi nding(ds, tableName)
    >
    >but in 2008 with the datagridview setdatabinding doesn't exist.
    DataGridView1.D ataSource = myds

    Comment

    • Rich P

      #3
      Re: how do I link a datagridview to a dataset?

      I had problems using databinding so I just did this:

      datagridview1.d ataSource = dataset1.Tables ("stevedog")

      and you can set a currencyManager object like this

      dim curMg As CurrencyManager

      curMgr = Ctype(Me.Bindin gContext(datase t1.Tables("stev edog"),
      CurrencyManger)

      CurMgr.Position = 0
      txtPos.Text = (CurMgr.Positio n + 1).ToString
      txtCount.Text = CurMgr.Count.To String

      You can increment CurMgr like this

      CurMgr.Position += 1

      in the Click event of the datagridview or in the RowEnter event.



      Rich

      *** Sent via Developersdex http://www.developersdex.com ***

      Comment

      • Rich P

        #4
        Re: how do I link a datagridview to a dataset?

        I had problems using databinding so I just did this:

        datagridview1.d ataSource = dataset1.Tables ("stevedog")

        and you can set a currencyManager object like this

        dim curMg As CurrencyManager

        curMgr = Ctype(Me.Bindin gContext(datase t1.Tables("stev edog"),
        CurrencyManger)

        CurMgr.Position = 0
        txtPos.Text = (CurMgr.Positio n + 1).ToString
        txtCount.Text = CurMgr.Count.To String

        You can increment CurMgr like this

        CurMgr.Position += 1

        in the Click event of the datagridview or in the RowEnter event.



        Rich

        Rich

        *** Sent via Developersdex http://www.developersdex.com ***

        Comment

        • cj

          #5
          Re: how do I link a datagridview to a dataset?

          Thanks, I took your advise.

          Rich P wrote:
          I had problems using databinding so I just did this:
          >
          datagridview1.d ataSource = dataset1.Tables ("stevedog")
          >
          and you can set a currencyManager object like this
          >
          dim curMg As CurrencyManager
          >
          curMgr = Ctype(Me.Bindin gContext(datase t1.Tables("stev edog"),
          CurrencyManger)
          >
          CurMgr.Position = 0
          txtPos.Text = (CurMgr.Positio n + 1).ToString
          txtCount.Text = CurMgr.Count.To String
          >
          You can increment CurMgr like this
          >
          CurMgr.Position += 1
          >
          in the Click event of the datagridview or in the RowEnter event.
          >
          >
          >
          Rich
          >
          Rich
          >
          *** Sent via Developersdex http://www.developersdex.com ***

          Comment

          • Cor Ligthert[MVP]

            #6
            Re: how do I link a datagridview to a dataset?

            cj.

            The datasource in the DataGridView exist from version 2005, it exist in the
            DataGrid, the ListBox and the Combobox from version 2002.

            However, in version 2008 it is better to place the bindingsource between it
            as some problems are then fixed while behaviour in old programs stay the
            same.

            \\\
            Dim bs As New BindingSource
            bs.DataSource = dt
            DataGridView1.D ataSource = bs
            ////

            Cor


            "cj" <cj@nospam.nosp amschreef in bericht
            news:e6ukk6j0IH A.5728@TK2MSFTN GP06.phx.gbl...
            In VB 2008 how do I link the datagridview to a dataset?
            >
            mydataadapter.f ill(myds, "test")
            datagridview1.? ???????
            >
            When I was using 2005 I used the datagrid and it was done like:
            >
            mydataadapter.f ill(myds, "test")
            datagrid1.DataG rid1.SetDataBin ding(ds, tableName)
            >
            but in 2008 with the datagridview setdatabinding doesn't exist.

            Comment

            Working...