Question

I'm reasonably new to programming and soon I will be creating a program and would like to change the colour of a selected row via a button click.

I have been attempting this but I don't even know where to begin. If someone could point me in the correct direction it would be much appreciated.

Thanks ^.^

No correct solution

OTHER TIPS

You could simply create a new control, then change the designer to inherit from the listbox control.

the designer code would then look something like this (vs2010):

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class UserControl1
    Inherits ListBox

    'UserControl overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        components = New System.ComponentModel.Container()
    End Sub

End Class

To see the designer code, select "Show All Files" (button at the top of your solution explorer). Then expand the new control node in your solution explorer.

then change the line:

Inherits System.Windows.Forms.UserControl

to:

Inherits ListBox

and finally delete delete the line:

Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font

Hope that helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top