0

Sir,

Please anybody help me while I am inserting the data through textbox of the selected item of the list box I want the when the user will input the data into textbox and then pressing the insert button the the selected item of list box (selected item only color change) color change white into blue or red.

kindly help me out.

Please

1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by jallan2010
-2

Sir,

Please anybody help me while I am inserting the data through textbox of the selected item of the list box I want the when the user will input the data into textbox and then pressing the insert button the the selected item of list box (selected item only color change) color change white into blue or red.

kindly help me out.

Private Sub lblani_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles lblani.DrawItem

        If txtlani.Text = "" Then
            'lblani.SelectedItem = colo

        Else
            ' Draw the background of the ListBox control for each item.
            e.DrawBackground()

            ' Define the default color of the brush as black.
            Dim myBrush As Brush = Brushes.Black

            ' Determine the color of the brush to draw each item based on   
            ' the index of the item to draw.
            Select Case e.Index

                Case 1
                    myBrush = Brushes.Orange

            End Select

            ' Draw the current item text based on the current 
            ' Font and the custom brush settings.
            e.Graphics.DrawString(lblani.Items(e.Index).ToString(), _
                e.Font, myBrush, e.Bounds, StringFormat.GenericDefault)

            ' If the ListBox has focus, draw a focus rectangle around  _ 
            ' the selected item.
            e.DrawFocusRectangle()
        End If



    End Sub

Private Sub lblani_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles lblani.DrawItem

        If txtlani.Text = "" Then
            'lblani.SelectedItem = colo

        Else
            ' Draw the background of the ListBox control for each item.
            e.DrawBackground()

            ' Define the default color of the brush as black.
            Dim myBrush As Brush = Brushes.Black

            ' Determine the color of the brush to draw each item based on   
            ' the index of the item to draw.
            Select Case e.Index

                Case 1
                    myBrush = Brushes.Orange

            End Select

            ' Draw the current item text based on the current 
            ' Font and the custom brush settings.
            e.Graphics.DrawString(lblani.Items(e.Index).ToString(), _
                e.Font, myBrush, e.Bounds, StringFormat.GenericDefault)

            ' If the ListBox has focus, draw a focus rectangle around  _ 
            ' the selected item.
            e.DrawFocusRectangle()
        End If



    End Sub

Edited by Nick Evan: Fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.