How can I do it?

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

    How can I do it?

    Hi, all,

    If I want to datagrid1 locate to row where dno="002",how can I do it?


    Dim Conn As String = "Provider=vfpol edb;Data
    Source=H:\BACKU P\NEWBACK1\RSKJ GZ7\BACKNGX\DAT A\gxrs.dbc"
    Da = New OleDbDataAdapte r("Select Dno,Dname From Department", Conn)
    dt = New DataTable
    Da.Fill(dt)
    DataGrid1.DataS ource=dt

    Thanks in advance!

    Chuen


  • Lucas Tam

    #2
    Re: How can I do it?

    "Chuen" <cnchuen@hotmai l.com> wrote in news:Oi6TqnKjEH A.2412
    @TK2MSFTNGP15.p hx.gbl:
    [color=blue]
    > If I want to datagrid1 locate to row where dno="002",how can I do it?[/color]

    Apply a dataview. Or you can use the datatable's select method. Or you can
    use the Find method (assuming dno is the PK).

    --
    Lucas Tam (REMOVEnntp@rog ers.com)
    Please delete "REMOVE" from the e-mail address when replying.

    Comment

    • Cor Ligthert

      #3
      Re: How can I do it?

      Lucas,

      As addition to Lucas, his answer and than: using the underlaying datasourcre
      in your sample "dt".

      Cor
      [color=blue]
      > Hi, all,
      >
      > If I want to datagrid1 locate to row where dno="002",how can I do it?
      >
      >
      > Dim Conn As String = "Provider=vfpol edb;Data
      > Source=H:\BACKU P\NEWBACK1\RSKJ GZ7\BACKNGX\DAT A\gxrs.dbc"
      > Da = New OleDbDataAdapte r("Select Dno,Dname From Department", Conn)
      > dt = New DataTable
      > Da.Fill(dt)
      > DataGrid1.DataS ource=dt
      >
      > Thanks in advance!
      >
      > Chuen
      >
      >[/color]


      Comment

      • Chuen

        #4
        Re: How can I do it?

        Can you give me any examples?
        Thanks In advance!

        Chuen

        "Chuen" <cnchuen@hotmai l.com> дÈëÓʼþ
        news:Oi6TqnKjEH A.2412@TK2MSFTN GP15.phx.gbl...[color=blue]
        > Hi, all,
        >
        > If I want to datagrid1 locate to row where dno="002",how can I do it?
        >
        >
        > Dim Conn As String = "Provider=vfpol edb;Data
        > Source=H:\BACKU P\NEWBACK1\RSKJ GZ7\BACKNGX\DAT A\gxrs.dbc"
        > Da = New OleDbDataAdapte r("Select Dno,Dname From Department", Conn)
        > dt = New DataTable
        > Da.Fill(dt)
        > DataGrid1.DataS ource=dt
        >
        > Thanks in advance!
        >
        > Chuen
        >
        >[/color]


        Comment

        • Ken Tucker [MVP]

          #5
          Re: How can I do it?

          Hi,



          Ken
          ----------------------
          "Chuen" <cnchuen@hotmai l.com> wrote in message
          news:eZ1o83OjEH A.1404@TK2MSFTN GP09.phx.gbl...
          Can you give me any examples?
          Thanks In advance!

          Chuen

          "Chuen" <cnchuen@hotmai l.com> дÈëÓʼþ
          news:Oi6TqnKjEH A.2412@TK2MSFTN GP15.phx.gbl...[color=blue]
          > Hi, all,
          >
          > If I want to datagrid1 locate to row where dno="002",how can I do it?
          >
          >
          > Dim Conn As String = "Provider=vfpol edb;Data
          > Source=H:\BACKU P\NEWBACK1\RSKJ GZ7\BACKNGX\DAT A\gxrs.dbc"
          > Da = New OleDbDataAdapte r("Select Dno,Dname From Department", Conn)
          > dt = New DataTable
          > Da.Fill(dt)
          > DataGrid1.DataS ource=dt
          >
          > Thanks in advance!
          >
          > Chuen
          >
          >[/color]



          Comment

          • Cor Ligthert

            #6
            Re: How can I do it?

            Chueng,

            Maybe, however tell first something more what you want to archieve, because
            (not knowing how it is with others) for me that is not clear.

            The simplest answer on your question had been by instance, go to your screen
            take the mouse and click on that row. However I assume that is not what you
            want.

            Cor
            [color=blue]
            > Can you give me any examples?
            > Thanks In advance!
            >
            > Chuen[/color]


            Comment

            • Chuen

              #7
              Re: How can I do it?

              Thanks for your response, in my example as following,

              Dim Conn As String = "Provider=vfpol edb;Data
              Source=H:\BACKU P\NEWBACK1\RSKJ GZ7\BACKNGX\DAT A\gxrs.dbc"
              Da = New OleDbDataAdapte r("Select Dno,Dname From Department", Conn)
              dt = New DataTable
              Da.Fill(dt)
              DataGrid1.DataS ource=dt

              dt has totally 800 rows. I means, if I put a command button(Cation: Find)
              and a textbox named DnoText in form(which datagrid1 locates), when I input
              any value in textbox and then click such command button, the datagrid1 will
              locate to the row whose dno is value input in DnoText.

              Thanks and hope that you can give me any idea!

              Chuen

              "Cor Ligthert" <notfirstname@p lanet.nl> дÈëÓʼþ
              news:uqVcY6OjEH A.4092@TK2MSFTN GP10.phx.gbl...[color=blue]
              > Chueng,
              >
              > Maybe, however tell first something more what you want to archieve,[/color]
              because[color=blue]
              > (not knowing how it is with others) for me that is not clear.
              >
              > The simplest answer on your question had been by instance, go to your[/color]
              screen[color=blue]
              > take the mouse and click on that row. However I assume that is not what[/color]
              you[color=blue]
              > want.
              >
              > Cor
              >[color=green]
              > > Can you give me any examples?
              > > Thanks In advance!
              > >
              > > Chuen[/color]
              >
              >[/color]


              Comment

              • Chuen

                #8
                Re: How can I do it?

                Thanks, but I can't access that address!

                "Ken Tucker [MVP]" <vb2ae@bellsout h.net> дÈëÓʼþ
                news:%23AzbG7Oj EHA.556@tk2msft ngp13.phx.gbl.. .[color=blue]
                > Hi,
                >
                > http://www.onteorasoftware.com/downl...taviewfind.zip
                >
                > Ken
                > ----------------------
                > "Chuen" <cnchuen@hotmai l.com> wrote in message
                > news:eZ1o83OjEH A.1404@TK2MSFTN GP09.phx.gbl...
                > Can you give me any examples?
                > Thanks In advance!
                >
                > Chuen
                >
                > "Chuen" <cnchuen@hotmai l.com> дÈëÓʼþ
                > news:Oi6TqnKjEH A.2412@TK2MSFTN GP15.phx.gbl...[color=green]
                > > Hi, all,
                > >
                > > If I want to datagrid1 locate to row where dno="002",how can I do it?
                > >
                > >
                > > Dim Conn As String = "Provider=vfpol edb;Data
                > > Source=H:\BACKU P\NEWBACK1\RSKJ GZ7\BACKNGX\DAT A\gxrs.dbc"
                > > Da = New OleDbDataAdapte r("Select Dno,Dname From Department", Conn)
                > > dt = New DataTable
                > > Da.Fill(dt)
                > > DataGrid1.DataS ource=dt
                > >
                > > Thanks in advance!
                > >
                > > Chuen
                > >
                > >[/color]
                >
                >
                >[/color]


                Comment

                • Cor Ligthert

                  #9
                  Re: How can I do it?

                  Chuen,

                  The only simple idea I can come up is this.
                  (For this your datagrid should absolutly be set with sort off)

                  I hope this helps?

                  Cor
                  \\\ needs 1 datagrid 1 button and 1 textbox
                  Dim dt As New DataTable
                  Private Sub Form1_Load(ByVa l sender As Object, _
                  ByVal e As System.EventArg s) Handles MyBase.Load
                  dt.Columns.Add( "datet", GetType(System. DateTime))
                  For i As Integer = 0 To 800
                  Dim dr As DataRow = dt.NewRow
                  dr(0) = Now.Date.AddDay s(i)
                  dt.Rows.Add(dr)
                  Next
                  DataGrid1.DataS ource = dt
                  DataGrid1.Allow Sorting = False
                  End Sub

                  Private Sub Button1_Click(B yVal sender As System.Object, _
                  ByVal e As System.EventArg s) Handles Button1.Click
                  Dim mdt As Date = CDate(TextBox1. Text)
                  For I As Integer = 0 To 800
                  If DirectCast(dt.R ows(I)(0), Date) = mdt Then
                  DataGrid1.Selec t(I)
                  Exit Sub
                  End If
                  Next
                  End Sub
                  ///


                  Comment

                  Working...