Select/Filter/Search Data in DataGrid View?

cvsforce

New member
Joined
Sep 18, 2006
Messages
2
Programming Experience
1-3
I am just begin to use databases in my projects so I am not too good in
such programming. I have "simple"(for me is not simple) question,
HOW I CAN SELECT ROW IN DATAGRID VIEW, Throughout TYPED CRITERIA?

When I select first radiobutton I search only data in 1-st column, the
second button - second column search.

I posted pictures below to show what I think. Thanks!

ScreenShoot000.jpg (shows concept(look of program-simplified))

ScreenShoot001.jpg (Shows running program and "selection by typed criteria")

ScreenShoot002.jpg (Like ScreenShoot001 but second radiobutton selected
and corresponding columun selected)

Project Elements:

1 DataGrid View - DataGridView1
2 RadioButtons - RadioButton1, RadioButton2
1 Text Box - Textbox1
1 DataSet - VDataSet
1 BindingSource - MFBindingSource
1 TableAdapter - MFTableAdapter

The whole DataBase Connection is auto generated by VS2005 - VB.NET

IS THIS DIFICULT TO MAKE, AND HOW? HTANKS!:confused:
 

Attachments

  • ScreenShot000.jpg
    ScreenShot000.jpg
    26.2 KB · Views: 41
  • ScreenShot001.jpg
    ScreenShot001.jpg
    26.3 KB · Views: 40
  • ScreenShot002.jpg
    ScreenShot002.jpg
    23.2 KB · Views: 38
There's probably an easier way, but this should work:

Dim Row as Integer
Dim Column as Integer

If RadioButton1.Selected Then
Column = 0
ElseIf RadioButton2.Selected Then
Column = 1
End if

For Row = 0 to (Me.DataGridView.RowCount-1)
If Me.DataGridView.Rows(Row).Cells(Column).Value = TextBox.Text Then
Me.DataGridView.Rows(Row).Selected = True
End If
Next


That will hilite all rows that meet the search criteria.
 
Back
Top