Click here to Skip to main content
15,915,065 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionsugestion requested for displaying of information Pin
droolin26-Jun-10 17:09
droolin26-Jun-10 17:09 
AnswerRe: sugestion requested for displaying of information Pin
DaveAuld26-Jun-10 20:06
professionalDaveAuld26-Jun-10 20:06 
GeneralRe: sugestion requested for displaying of information Pin
droolin26-Jun-10 20:39
droolin26-Jun-10 20:39 
QuestionPrograms For Mobiles - VB.Net 2008 Pin
Paramu197326-Jun-10 3:11
Paramu197326-Jun-10 3:11 
AnswerRe: Programs For Mobiles - VB.Net 2008 Pin
DaveAuld26-Jun-10 3:32
professionalDaveAuld26-Jun-10 3:32 
GeneralRe: Programs For Mobiles - VB.Net 2008 Pin
Paramu197326-Jun-10 21:06
Paramu197326-Jun-10 21:06 
QuestionDataGrid Window Forms Pin
.NetDeveloper0925-Jun-10 8:34
.NetDeveloper0925-Jun-10 8:34 
AnswerRe: DataGrid Window Forms Pin
DaveAuld25-Jun-10 9:44
professionalDaveAuld25-Jun-10 9:44 
The code below is what I am using to provide Find functionality (including Match Case or Match Exact options) on a datagrid.

In it you will see how it iterates all rows and columns and reads the cell values to allow the compare etc. Think it shows you everything you need;

VB
Private Sub searchForm_FindNext(ByVal SearchText As String, ByVal MatchCase As Boolean, ByVal MatchExact As Boolean) Handles searchForm.FindNext
        If (DataResults.RowCount > 0) AndAlso (SearchText.Length > 0) Then
            Dim offset As Integer = 1           'Use 1 for when searching next, or set to 0 when wrapping to first row
            Dim rowIndex As Integer

            If DataResults.CurrentRow.Index = DataResults.Rows.Count - 1 Then
                'You are on the last row
                If MessageBox.Show("You are on the last row, go back to the start?", "Find In Results", MessageBoxButtons.YesNo) = vbYes Then
                    DataResults.Rows.Item(0).Selected = True
                    BindingNavigatorMoveFirstItem.PerformClick()
                    offset = 0
                Else
                    Exit Sub
                End If
            End If

            For rowIndex = DataResults.CurrentRow.Index + offset To DataResults.Rows.Count - 1

                For Each cell As DataGridViewCell In DataResults.Rows.Item(rowIndex).Cells
                    If cell.ValueType.Equals(GetType(String)) Then

                        If MatchCase AndAlso MatchExact Then
                            If cell.Value.ToString.Equals(SearchText) Then
                                FindNextMatched(rowIndex)
                                Exit Sub
                            End If
                        ElseIf MatchCase Then
                            If cell.Value.ToString.Contains(SearchText) Then
                                FindNextMatched(rowIndex)
                                Exit Sub
                            End If

                        ElseIf MatchExact Then
                            If cell.Value.ToString.ToUpper.Equals(SearchText.ToUpper) Then
                                FindNextMatched(rowIndex)
                                Exit Sub
                            End If
                        Else
                            If cell.Value.ToString.ToUpper.Contains(SearchText.ToUpper) Then
                                FindNextMatched(rowIndex)
                                Exit Sub
                            End If
                        End If

                    End If
                Next

                If rowIndex = DataResults.Rows.Count - 1 Then
                    If MessageBox.Show("End of results reached, do you want to search from the start again?", "End of Results Reached", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
                        rowIndex = 0
                    End If
                End If
            Next
        End If
    End Sub


Hope that helps!
Dave

Don't forget to rate messages!
Find Me On: Web|Facebook|Twitter|LinkedIn
Waving? dave.m.auld[at]googlewave.com


GeneralRe: DataGrid Window Forms [modified] Pin
.NetDeveloper0926-Jun-10 6:38
.NetDeveloper0926-Jun-10 6:38 
GeneralRe: DataGrid Window Forms Pin
DaveAuld26-Jun-10 7:02
professionalDaveAuld26-Jun-10 7:02 
GeneralRe: DataGrid Window Forms Pin
.NetDeveloper0926-Jun-10 7:16
.NetDeveloper0926-Jun-10 7:16 
GeneralRe: DataGrid Window Forms Pin
DaveAuld26-Jun-10 7:53
professionalDaveAuld26-Jun-10 7:53 
GeneralRe: DataGrid Window Forms [modified] Pin
DaveAuld26-Jun-10 8:24
professionalDaveAuld26-Jun-10 8:24 
GeneralRe: DataGrid Window Forms Pin
.NetDeveloper0926-Jun-10 13:12
.NetDeveloper0926-Jun-10 13:12 
Questionsearch items in Datagridview Pin
zafax_25-Jun-10 1:21
zafax_25-Jun-10 1:21 
AnswerRe: search items in Datagridview Pin
Scubapro25-Jun-10 2:05
Scubapro25-Jun-10 2:05 
GeneralRe: search items in Datagridview Pin
zafax_25-Jun-10 2:36
zafax_25-Jun-10 2:36 
GeneralRe: search items in Datagridview Pin
Scubapro25-Jun-10 3:03
Scubapro25-Jun-10 3:03 
GeneralRe: search items in Datagridview Pin
zafax_25-Jun-10 5:41
zafax_25-Jun-10 5:41 
GeneralRe: search items in Datagridview Pin
riced25-Jun-10 6:09
riced25-Jun-10 6:09 
GeneralRe: search items in Datagridview Pin
Eddy Vluggen25-Jun-10 6:41
professionalEddy Vluggen25-Jun-10 6:41 
GeneralRe: search items in Datagridview Pin
zafax_25-Jun-10 21:38
zafax_25-Jun-10 21:38 
GeneralRe: search items in Datagridview Pin
Eddy Vluggen26-Jun-10 1:11
professionalEddy Vluggen26-Jun-10 1:11 
GeneralRe: search items in Datagridview Pin
zafax_26-Jun-10 4:13
zafax_26-Jun-10 4:13 
GeneralRe: search items in Datagridview Pin
Eddy Vluggen26-Jun-10 5:02
professionalEddy Vluggen26-Jun-10 5:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.