Hello
Im attaching a screen shot of output i get through my project...
The following code is :
Private Sub frmSearchResults_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' from here start executing query and fetching data in panels and adding panels in main panel...
Try
' connect to database
Dim myConnection As New MySqlConnection
myConnection = Connection.AutoConnect
Dim myCommand As MySqlCommand
myCommand = New MySqlCommand(query, myConnection)
Dim objReader As MySqlDataReader = myCommand.ExecuteReader
Dim pnl_y_pos As Long = 0
While objReader.Read
' for each record create a new panel...
' keep track of laction of next panel...
' now first get infromation and pack it in textbox...
Dim txtInBox As String
txtInBox = "Student ID : (" & objReader.Item("SID") & ")" & vbCrLf
txtInBox &= "Name : " & objReader.Item("Name") & vbCrLf
txtInBox &= "Father Name : " & objReader.Item("FName") & vbCrLf
txtInBox &= "Roll Number : " & objReader.Item("RollNo") & vbCrLf
txtInBox &= "Section : " & objReader.Item("Section") & vbCrLf
txtInBox &= "Residential Address : " & objReader.Item("ResAddr") & vbCrLf
' Please start reading from here
' create a new panel...
Dim objPanel As New Panel
' create a new information text box
Dim objNewBox As New TextBox
' create a new picture box...
Dim objPicBox As New PictureBox
' create a new view full details,update and delete button
Dim objViewFull As New Button, objUpdate As New Button, objDelete As New Button
' now set properties of these all object and add in current panel...
' first for information box
objNewBox.Multiline = True
objNewBox.ScrollBars = ScrollBars.Vertical
objNewBox.Text = txtInBox
objNewBox.ReadOnly = True
objNewBox.Size = New Size(280, 150)
objNewBox.Location = New Point(176, 8)
objNewBox.TabStop = False
objPicBox.SizeMode = PictureBoxSizeMode.StretchImage
objPicBox.Image = DBFunctions.GetPictureFromDB(objReader.Item("SID"))
objPicBox.Size = New Size(160, 150)
objPicBox.Location = New Point(8, 8)
objViewFull.Text = "&View Full Details"
objViewFull.Size = New Size(96, 24)
objViewFull.Location = New Point(200, 168)
objUpdate.Text = "&Update"
objUpdate.Size = New Size(80, 24)
objUpdate.Location = New Point(296, 168)
objDelete.Text = "&Delete"
objDelete.Size = New Size(80, 24)
objDelete.Location = New Point(376, 168)
' now add these objects
objPanel.Controls.Add(objNewBox)
objPanel.Controls.Add(objPicBox)
objPanel.Controls.Add(objViewFull)
objPanel.Controls.Add(objUpdate)
objPanel.Controls.Add(objDelete)
' define a locaton for this panel...
objPanel.Location = New Point(8, pnl_y_pos)
objPanel.Size = New Size(464, 200)
' add handlers to all objects
' add handler to panel to test if panel is selected then change back color...
'AddHandler objPanel.Click, AddressOf _ChangeBackColor
AddHandler objPanel.Click, AddressOf SetPanelColours
'AddHandler objPanel.Click, AddressOf SetPanelColours
' add handlers to the buttons...
AddHandler objViewFull.Click, AddressOf _ViewFullDetails
AddHandler objUpdate.Click, AddressOf _Update
AddHandler objDelete.Click, AddressOf _Delete
' increment it for the next panel position
pnl_y_pos += 250
' now add this panel in main panel...
pnlMain.Controls.Add(objPanel)
End While
' higlight the first panel...
Me.pnlMain.Controls(0).BackColor = SystemColors.Highlight
Me.pnlMain.Controls(0).ForeColor = SystemColors.HighlightText
Catch ex As Exception
MsgBox("ERROR OCCURED IN SEARCH RESULTS : " & vbCrLf & ex.ToString)
End Try
End Sub
I have marked in red which is of my interest for you to read as remaining is not necessary...
Not i have told you details...
Please tell me where should i add and what should i add to do the panel Back Ground to Navy Blue and it seem as selected while remaining not...
Regards