Emerging a button in the ListViewItem

callraheel

Well-known member
Joined
Dec 12, 2004
Messages
65
Location
London,UK
Programming Experience
1-3
Hello
when we add , remove any program from our OS then in windows we go in ADD REMOVE Programs. Well there we can find i guess a list view and that displays all installed programs. When we click a program then there are buttons like 'Add,Change or Remove' depending on the program.
I want to know how to add those buttons to the list view as the project im working requires something like that
Moreover if picture control is added also then it will be more helpful for me!

Regards
Raheel
 
I put two Panels on a form and used the code from my previous post and it worked. Either you have done something wrong, or you haven't taken into account the fact that you are handling the Click event for the Panels themselves but not the controls on them. If you click a control on a Panel, like a Label, the Panel's Click event is not raised. You would have to handle the Click event of each control on the Panel as well. You can still use the same method to handle all events. You just have to get the Parent of any controls that are not Panels instead of the control itself.

As for using the arrows to move up and down, the Panel has no keyboard-related events so you would have to set the form's KeyPreview property to True and handle the arrows in the form's KeyDown event. Notice that if you depress an arrow and keep it depressed the selection will keep on scrolling. If you want to duplicate this behaviour you could Start a Timer on the KeyDown event and use the Timer to scroll down. You would then Stop the Timer on the KeyUp event.
 
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
 

Attachments

  • screen_shot.JPG
    screen_shot.JPG
    58.1 KB · Views: 146
Looking at that screenshot makes me think even more that this was a job for a regular ListView. You should have had a column for each of these fields, a single button for each of the three functions instead of three for each entry, and then just show the picture for the selected row. You could even have allowed the user to switch views from thumbnails to detail.

Also, if all those Panels of yours have the same structure then you should have created a UserControl that you could then handle as a unit. I'm afraid I've done all I can for you with this current method. You'll have to clean up your objects a bit and post back or get more help elsewhere.
 
Well actually the same List View Technique i have used before in my earlier project and thats why i was looking for a new way to do this but as you r saying so i think i should move back to the same procedure...

Anyways thanx for your help

Regards
Raheel
 
Back
Top