Datagridview Search?

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

    Datagridview Search?

    Hello,

    How do you search a datagridview for given column values?

    Any help would be greatly appreciated!
    Thanks in advance
  • gene kelley

    #2
    Re: Datagridview Search?

    On Tue, 22 Aug 2006 16:21:01 -0700, Mark <Mark@discussio ns.microsoft.co mwrote:
    >Hello,
    >
    >How do you search a datagridview for given column values?
    >
    >Any help would be greatly appreciated!
    >Thanks in advance
    1) If the control is bound to an underlying DataTable or DataSet, it would be better to search there
    rather than search the control.

    2) If unbound, you would have to iterate through all the rows looking for the specified column value
    using somthing like this:

    If Me.MainGridView .Rows(Index as Integer).Cells( ColumnName as String).Value = MyValue Then

    End If

    Gene

    Comment

    • Cor Ligthert [MVP]

      #3
      Re: Datagridview Search?

      Gene,

      AFAIK can a DataGridView not be used unbound althouhg it should be easier
      than with the DataGrid to bind it to another object.

      I would have written your first sentence if you had not done it already.

      Cor

      "gene kelley" <okay@by.meschr eef in bericht
      news:467ne2l2b7 202je98i7hbr2bi 6m7rrvje4@4ax.c om...
      On Tue, 22 Aug 2006 16:21:01 -0700, Mark <Mark@discussio ns.microsoft.co m>
      wrote:
      >
      >>Hello,
      >>
      >>How do you search a datagridview for given column values?
      >>
      >>Any help would be greatly appreciated!
      >>Thanks in advance
      >
      1) If the control is bound to an underlying DataTable or DataSet, it would
      be better to search there
      rather than search the control.
      >
      2) If unbound, you would have to iterate through all the rows looking for
      the specified column value
      using somthing like this:
      >
      If Me.MainGridView .Rows(Index as Integer).Cells( ColumnName as
      String).Value = MyValue Then
      >
      End If
      >
      Gene

      Comment

      • gene kelley

        #4
        Re: Datagridview Search?

        On Wed, 23 Aug 2006 07:28:52 +0200, "Cor Ligthert [MVP]" <notmyfirstname @planet.nlwrote :
        >Gene,
        >
        >AFAIK can a DataGridView not be used unbound althouhg it should be easier
        >than with the DataGrid to bind it to another object.
        >
        I'm not sure what you are trying to say in the above sentence. Are you asking how the DataGridView
        is used with unbound data?


        Gene

        >I would have written your first sentence if you had not done it already.
        >
        >Cor
        >
        >"gene kelley" <okay@by.meschr eef in bericht
        >news:467ne2l2b 7202je98i7hbr2b i6m7rrvje4@4ax. com...
        >On Tue, 22 Aug 2006 16:21:01 -0700, Mark <Mark@discussio ns.microsoft.co m>
        >wrote:
        >>
        >>>Hello,
        >>>
        >>>How do you search a datagridview for given column values?
        >>>
        >>>Any help would be greatly appreciated!
        >>>Thanks in advance
        >>
        >1) If the control is bound to an underlying DataTable or DataSet, it would
        >be better to search there
        >rather than search the control.
        >>
        >2) If unbound, you would have to iterate through all the rows looking for
        >the specified column value
        >using somthing like this:
        >>
        >If Me.MainGridView .Rows(Index as Integer).Cells( ColumnName as
        >String).Valu e = MyValue Then
        >>
        >End If
        >>
        >Gene
        >

        Comment

        • Cor Ligthert [MVP]

          #5
          Re: Datagridview Search?

          Gene,

          In my idea that is impossible yes, therefore maybe you can show it with a
          sample.

          Cor

          "gene kelley" <okay@by.meschr eef in bericht
          news:at7qe2hfns 560oq8jh91guf9u hfsm0g9fc@4ax.c om...
          On Wed, 23 Aug 2006 07:28:52 +0200, "Cor Ligthert [MVP]"
          <notmyfirstname @planet.nlwrote :
          >
          >>Gene,
          >>
          >>AFAIK can a DataGridView not be used unbound althouhg it should be easier
          >>than with the DataGrid to bind it to another object.
          >>
          I'm not sure what you are trying to say in the above sentence. Are you
          asking how the DataGridView
          is used with unbound data?
          >
          >
          Gene
          >
          >
          >>I would have written your first sentence if you had not done it already.
          >>
          >>Cor
          >>
          >>"gene kelley" <okay@by.meschr eef in bericht
          >>news:467ne2l2 b7202je98i7hbr2 bi6m7rrvje4@4ax .com...
          >>On Tue, 22 Aug 2006 16:21:01 -0700, Mark
          >><Mark@discuss ions.microsoft. com>
          >>wrote:
          >>>
          >>>>Hello,
          >>>>
          >>>>How do you search a datagridview for given column values?
          >>>>
          >>>>Any help would be greatly appreciated!
          >>>>Thanks in advance
          >>>
          >>1) If the control is bound to an underlying DataTable or DataSet, it
          >>would
          >>be better to search there
          >>rather than search the control.
          >>>
          >>2) If unbound, you would have to iterate through all the rows looking
          >>for
          >>the specified column value
          >>using somthing like this:
          >>>
          >>If Me.MainGridView .Rows(Index as Integer).Cells( ColumnName as
          >>String).Val ue = MyValue Then
          >>>
          >>End If
          >>>
          >>Gene
          >>

          Comment

          • gene kelley

            #6
            Re: Datagridview Search?

            On Thu, 24 Aug 2006 08:00:16 +0200, "Cor Ligthert [MVP]" <notmyfirstname @planet.nlwrote :
            >Gene,
            >
            >In my idea that is impossible yes, therefore maybe you can show it with a
            >sample.
            >
            >Cor
            >
            There is a trivial example in the Help file:
            Walkthrough: Creating An Unbound Windows Forms DataGridView Control

            Gene

            >"gene kelley" <okay@by.meschr eef in bericht
            >news:at7qe2hfn s560oq8jh91guf9 uhfsm0g9fc@4ax. com...
            >On Wed, 23 Aug 2006 07:28:52 +0200, "Cor Ligthert [MVP]"
            ><notmyfirstnam e@planet.nlwrot e:
            >>
            >>>Gene,
            >>>
            >>>AFAIK can a DataGridView not be used unbound althouhg it should be easier
            >>>than with the DataGrid to bind it to another object.
            >>>
            >I'm not sure what you are trying to say in the above sentence. Are you
            >asking how the DataGridView
            >is used with unbound data?
            >>
            >>
            >Gene
            >>
            >>
            >>>I would have written your first sentence if you had not done it already.
            >>>
            >>>Cor
            >>>
            >>>"gene kelley" <okay@by.meschr eef in bericht
            >>>news:467ne2l 2b7202je98i7hbr 2bi6m7rrvje4@4a x.com...
            >>>On Tue, 22 Aug 2006 16:21:01 -0700, Mark
            >>><Mark@discus sions.microsoft .com>
            >>>wrote:
            >>>>
            >>>>>Hello,
            >>>>>
            >>>>>How do you search a datagridview for given column values?
            >>>>>
            >>>>>Any help would be greatly appreciated!
            >>>>>Thanks in advance
            >>>>
            >>>1) If the control is bound to an underlying DataTable or DataSet, it
            >>>would
            >>>be better to search there
            >>>rather than search the control.
            >>>>
            >>>2) If unbound, you would have to iterate through all the rows looking
            >>>for
            >>>the specified column value
            >>>using somthing like this:
            >>>>
            >>>If Me.MainGridView .Rows(Index as Integer).Cells( ColumnName as
            >>>String).Valu e = MyValue Then
            >>>>
            >>>End If
            >>>>
            >>>Gene
            >>>
            >

            Comment

            • Cor Ligthert [MVP]

              #7
              Re: Datagridview Search?

              Gene,

              I did not know this, thanks,

              Cor

              "gene kelley" <okay@by.meschr eef in bericht
              news:mqlqe2h70g l5hbbboascge7ob p3g067015@4ax.c om...
              On Thu, 24 Aug 2006 08:00:16 +0200, "Cor Ligthert [MVP]"
              <notmyfirstname @planet.nlwrote :
              >
              >>Gene,
              >>
              >>In my idea that is impossible yes, therefore maybe you can show it with a
              >>sample.
              >>
              >>Cor
              >>
              There is a trivial example in the Help file:
              Walkthrough: Creating An Unbound Windows Forms DataGridView Control
              >
              Gene
              >
              >
              >>"gene kelley" <okay@by.meschr eef in bericht
              >>news:at7qe2hf ns560oq8jh91guf 9uhfsm0g9fc@4ax .com...
              >>On Wed, 23 Aug 2006 07:28:52 +0200, "Cor Ligthert [MVP]"
              >><notmyfirstna me@planet.nlwro te:
              >>>
              >>>>Gene,
              >>>>
              >>>>AFAIK can a DataGridView not be used unbound althouhg it should be
              >>>>easier
              >>>>than with the DataGrid to bind it to another object.
              >>>>
              >>I'm not sure what you are trying to say in the above sentence. Are you
              >>asking how the DataGridView
              >>is used with unbound data?
              >>>
              >>>
              >>Gene
              >>>
              >>>
              >>>>I would have written your first sentence if you had not done it already.
              >>>>
              >>>>Cor
              >>>>
              >>>>"gene kelley" <okay@by.meschr eef in bericht
              >>>>news:467ne2 l2b7202je98i7hb r2bi6m7rrvje4@4 ax.com...
              >>>>On Tue, 22 Aug 2006 16:21:01 -0700, Mark
              >>>><Mark@discu ssions.microsof t.com>
              >>>>wrote:
              >>>>>
              >>>>>>Hello,
              >>>>>>
              >>>>>>How do you search a datagridview for given column values?
              >>>>>>
              >>>>>>Any help would be greatly appreciated!
              >>>>>>Thanks in advance
              >>>>>
              >>>>1) If the control is bound to an underlying DataTable or DataSet, it
              >>>>would
              >>>>be better to search there
              >>>>rather than search the control.
              >>>>>
              >>>>2) If unbound, you would have to iterate through all the rows looking
              >>>>for
              >>>>the specified column value
              >>>>using somthing like this:
              >>>>>
              >>>>If Me.MainGridView .Rows(Index as Integer).Cells( ColumnName as
              >>>>String).Val ue = MyValue Then
              >>>>>
              >>>>End If
              >>>>>
              >>>>Gene
              >>>>
              >>

              Comment

              Working...