Sir,

I am using 3 textbox and one listbox. I am successfully retrieve the data into listbox i want that item selected in a listbox enter the data by textbox once the value input into through text box that the selected item of a listbox will change the back color of selected item only.

Please help me.

I am appreciate any one answer.


Thanks in advance

Recommended Answers

All 7 Replies

Set DrawMode with OwnerDrawFixed and handle DrawItem event.

Sir,
Please give me details hits about it whether it on the textbox event handler or any other method or event i will use.

Please help me.

Add listbox and a textbox control onto the form.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ListBox1.Items.Add("One")
        ListBox1.Items.Add("Two")
        ListBox1.Items.Add("Three")
        ListBox1.Items.Add("Four")

        ListBox1.DrawMode = DrawMode.OwnerDrawVariable
        AddHandler ListBox1.DrawItem, AddressOf drawit
    End Sub
    Sub drawit(ByVal sender As Object, ByVal e As DrawItemEventArgs)
        e.DrawBackground()
        e.DrawFocusRectangle()


        If e.Index = ListBox1.SelectedIndex Then
            e.Graphics.DrawString(ListBox1.Items(e.Index), New Font("Arial", 10), Brushes.Red, e.Bounds.X, e.Bounds.Y)
        Else
            e.Graphics.DrawString(ListBox1.Items(e.Index), New Font("Arial", 10), Brushes.Black, e.Bounds.X, e.Bounds.Y)
        End If

    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        ListBox1.Text = TextBox1.Text
    End Sub

Sir,
That I am using 3 textboxes I am using in first textbox it had First Name and second text box I am using Last Name and in third textbox I am usign that persons date of birth.

My issue is I am successfully retrieve the data i.e. First Name and Last Name in the Listbox I want that the third Textbox if the user will leave blank then no change in the selected item i.e. i have retrive data color i.e. it is black in color and if the user input his date of birth into the third textbox then it should be red or blue color.

Only change if the user will input the data into 3rd textbox.

Please help me

Please show us your code work.

Sir,
Literally speaking I have no code but I had show in some other program that why I am asking for some code reply from the senior if you have.

Thank you sir

Sir,
Do you have any idea about that so please help me for that.

Or any single hint for my query. You are a senior that's why i am prayer to help me.


Thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.