Click here to Skip to main content
15,920,801 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Could someone explain why For Each and For Next loops behave differently with lists? Pin
Eddy Vluggen9-Sep-18 2:11
professionalEddy Vluggen9-Sep-18 2:11 
GeneralRe: Could someone explain why For Each and For Next loops behave differently with lists? Pin
MattiasW7620-Sep-18 9:09
MattiasW7620-Sep-18 9:09 
AnswerRe: Could someone explain why For Each and For Next loops behave differently with lists? Pin
Dave Kreskowiak9-Sep-18 4:54
mveDave Kreskowiak9-Sep-18 4:54 
GeneralRe: Could someone explain why For Each and For Next loops behave differently with lists? Pin
MattiasW7627-Sep-18 2:59
MattiasW7627-Sep-18 2:59 
QuestionAdding Custom TabPage to TabControl: Closed Pin
mo14927-Sep-18 11:12
mo14927-Sep-18 11:12 
QuestionHow to declare Crypto? Pin
Member 139535037-Sep-18 6:04
Member 139535037-Sep-18 6:04 
AnswerRe: How to declare Crypto? Pin
Richard Deeming7-Sep-18 7:46
mveRichard Deeming7-Sep-18 7:46 
GeneralRe: How to declare Crypto? Pin
Member 1395350314-Sep-18 3:19
Member 1395350314-Sep-18 3:19 
QuestionCurrency textbox Pin
Member 139744835-Sep-18 16:08
Member 139744835-Sep-18 16:08 
AnswerRe: Currency textbox Pin
Mycroft Holmes5-Sep-18 18:34
professionalMycroft Holmes5-Sep-18 18:34 
AnswerRe: Currency textbox Pin
dan!sh 5-Sep-18 19:56
professional dan!sh 5-Sep-18 19:56 
Questionwindows version in vb.net Pin
JR2123-Sep-18 0:20
JR2123-Sep-18 0:20 
AnswerRe: windows version in vb.net Pin
Eddy Vluggen3-Sep-18 1:45
professionalEddy Vluggen3-Sep-18 1:45 
AnswerRe: windows version in vb.net Pin
Dave Kreskowiak3-Sep-18 13:31
mveDave Kreskowiak3-Sep-18 13:31 
QuestionHow to multi Highlight text different 2 textbox in datagridview VB.net? Pin
CodieCalm2-Sep-18 22:26
CodieCalm2-Sep-18 22:26 
Private Sub DataGridView1_CellPainting(ByVal sender As Object, ByVal e As DataGridViewCellPaintingEventArgs) Handles DataGridView1.CellPainting
        'If there is no search string, no rows, or nothing in this cell, then get out. 
        If ComboBox1.Text = String.Empty Then Return
        If (e.Value Is Nothing) Then Return
        If e.RowIndex < 0 Or e.ColumnIndex < 0 Then Return

        e.Handled = True
        e.PaintBackground(e.CellBounds, True)

        'Get the value of the text in the cell, and the search term. Work with everything in lowercase for more accurate highlighting
        Dim str_SearchTerm As String = ComboBox1.Text.Trim.ToLower
        Dim str_CellText As String = DirectCast(e.FormattedValue, String).ToLower

        'Create a list of the character ranges that need to be highlighted. We need to know the start index and the length
        Dim HLRanges As New List(Of CharacterRange)
        Dim SearchIndex As Integer = str_CellText.IndexOf(str_SearchTerm)
        Do Until SearchIndex = -1
            HLRanges.Add(New CharacterRange(SearchIndex, str_SearchTerm.Length))
            SearchIndex = str_CellText.IndexOf(str_SearchTerm, SearchIndex + str_SearchTerm.Length)
        Loop

        ' We also work with the original cell text which is has not been converted to lowercase, else the sizes are incorrect
        str_CellText = DirectCast(e.FormattedValue, String)

        ' Choose your colours. A different colour is used on the currently selected rows
        Dim HLColour As SolidBrush
        If ((e.State And DataGridViewElementStates.Selected) <> DataGridViewElementStates.None) Then
            HLColour = New SolidBrush(Color.DarkGoldenrod)
        Else
            HLColour = New SolidBrush(Color.Yellow)
        End If

        'Loop through all of the found instances and draw the highlight box
        For Each HLRange In HLRanges

            ' Create the rectangle. It should start just underneath the top of the cell, and go to just above the bottom
            Dim HLRectangle As New Rectangle()
            HLRectangle.Y = e.CellBounds.Y + 2
            HLRectangle.Height = e.CellBounds.Height - 5

            ' Determine the size of the text before the area to highlight, and the size of the text to highlight. 
            ' We need to know the size of the text before so that we know where to start the highlight rectangle
            Dim TextBeforeHL As String = str_CellText.Substring(0, HLRange.First)
            Dim TextToHL As String = str_CellText.Substring(HLRange.First, HLRange.Length)
            Dim SizeOfTextBeforeHL As Size = TextRenderer.MeasureText(e.Graphics, TextBeforeHL, e.CellStyle.Font, e.CellBounds.Size)
            Dim SizeOfTextToHL As Size = TextRenderer.MeasureText(e.Graphics, TextToHL, e.CellStyle.Font, e.CellBounds.Size)

            'Set the width of the rectangle, a little wider to make the highlight clearer
            If SizeOfTextBeforeHL.Width > 5 Then
                HLRectangle.X = e.CellBounds.X + SizeOfTextBeforeHL.Width - 6
                HLRectangle.Width = SizeOfTextToHL.Width - 6
            Else
                HLRectangle.X = e.CellBounds.X + 2
                HLRectangle.Width = SizeOfTextToHL.Width - 6
            End If

            'Paint the highlight area
            e.Graphics.FillRectangle(HLColour, HLRectangle)
        Next

        'Paint the rest of the cell as usual
        e.PaintContent(e.CellBounds)
    End Sub

QuestionCount char in string? Pin
Member 1395409621-Aug-18 22:43
Member 1395409621-Aug-18 22:43 
AnswerRe: Count char in string? Pin
Jochen Arndt21-Aug-18 23:32
professionalJochen Arndt21-Aug-18 23:32 
GeneralRe: Count char in string? Pin
Chris Quinn22-Aug-18 4:23
Chris Quinn22-Aug-18 4:23 
GeneralRe: Count char in string? Pin
Jochen Arndt22-Aug-18 5:08
professionalJochen Arndt22-Aug-18 5:08 
GeneralRe: Count char in string? Pin
Richard Deeming22-Aug-18 8:58
mveRichard Deeming22-Aug-18 8:58 
GeneralRe: Count char in string? Pin
Chris Quinn22-Aug-18 20:55
Chris Quinn22-Aug-18 20:55 
GeneralRe: Count char in string? Pin
Jochen Arndt22-Aug-18 21:16
professionalJochen Arndt22-Aug-18 21:16 
GeneralRe: Count char in string? Pin
Chris Quinn22-Aug-18 21:40
Chris Quinn22-Aug-18 21:40 
GeneralRe: Count char in string? Pin
Richard Deeming23-Aug-18 9:03
mveRichard Deeming23-Aug-18 9:03 
AnswerRe: Count char in string? Pin
Chris Quinn23-Aug-18 3:19
Chris Quinn23-Aug-18 3:19 

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.