I am programatically trying to add a background image to each item in a listbox control. The first attached screen shot is a mockup of what I am trying to achieve.
The second screenshot is what I have so far. I want the listbox at the bottom of the screen to display an image for each item as per first screen shot.
The full code is as per attached code snippet.
Thanks in advance for any help given.
An extract of the code is below:
'*******************************************
Private Sub LoadSuites()
Dim dt As New DataTable
Dim cmd As New SqlCommand
'dt = GetDataTable(AppConnection, _
' "usp_GetSuites", _
' "@UserID", UserID, _
' "@CompanyID", CompanyID, _
' "@Instance", Instance)
HttpContext.Current.Session("connStringValue") = GetConnectionString2()
Dim Conn As SqlConnection = New System.Data.SqlClient.SqlConnection(HttpContext.Current.Session("connStringValue") & ";Initial Catalog=" & sDBName)
Conn.Open()
cmd.Connection = Conn
cmd.CommandText = "usp_GetSuites"
cmd.CommandType = CommandType.StoredProcedure
'add command parameters
cmd.Parameters.Add("@UserID", SqlDbType.Decimal, 18, 0)
cmd.Parameters("@UserID").Value = UserID
cmd.Parameters.Add("@CompanyID", SqlDbType.Decimal, 18, 0)
cmd.Parameters("@CompanyID").Value = CompanyID
cmd.Parameters.Add("@Instance", SqlDbType.VarChar, 14)
cmd.Parameters("@Instance").Value = Instance
Dim daloader As New SqlDataAdapter(cmd)
Dim msgColor As New TableCell
daloader.Fill(dt)
'*******************************************
With lbxSuites
'.Attributes.Add("onmouseover", "this.style.cursor='pointer';")
.Attributes.Add("onmouseout", "this.style.cursor='default';")
'*******************************************
'.Attributes.Add("style", "display: visible;")
.Attributes.Add("onmouseover", "this.sytle.cursor='arrow';")
'.Style("background") = "Tan"
.Style("background-image") = "../Includes/Images/bg_button.png"
'*******************************************
.DataSource = dt
.DataTextField = "Suite"
.DataValueField = "Suite"
'.CssClass = "MenuHeader"
.DataBind()
' The listbox number of rows is set to 2 as asp.net renders
' listboxes with rows of 1 and below as DropDownlists
If dt.Rows.Count > 2 Then
.Rows = dt.Rows.Count
Else
.Rows = 2
End If
If dt.Rows.Count = 1 Then .Items(0).Selected = True
End With
End Sub
'****************************************************
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
-Mike Kapnisakis, Warner Bros
With your subscription - you'll gain access to our exclusive IT community of thousands of IT pros. You'll also be able to connect with highly specified Experts to get personalized solutions to your troubleshooting & research questions. It’s like crowd-sourced consulting.
We can't always guarantee that the perfect solution to your specific problem will be waiting for you. If you ask your own question - our Certified Experts will team up with you to help you get the answers you need.
Our certified Experts are CTOs, CISOs, and Technical Architects who answer questions, write articles, and produce videos on Experts Exchange. 99% of them have full time tech jobs - they volunteer their time to help other people in the technology industry learn and succeed.
We can't guarantee quick solutions - Experts Exchange isn't a help desk. We're a community of IT professionals committed to sharing knowledge. Our experts volunteer their time to help other people in the technology industry learn and succeed.
Our community of experts have been thoroughly vetted for their expertise and industry experience.