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
 
What you see in the Add/Remove programs dialogue is not a ListView. While it was not created using .NET, it is the equivalent of a Panel with AutoScroll set to True. Each program entry is also a Panel. When a program entry's Panel is clicked, its BackgroundColor is changed to show that it is selected and the contols, including a PictureBox, Labels, LinkLabels and Buttons, are displayed.
 
o i c... Thanx but will you please show me some example of it so that i can understand it more better and i need advise on on this thing as you say that it is not list view but i need to create a Search Result Dialog Box which contain something like this , Has buttons in it which are 'Update', 'Delete' and a picture box containing the picture of the person. But if i do it with panels...dont you think it will use much memory... so is there any way through i can do the same using minimum possible memory because records can be from be in the range of 20-200

Regards
 
You could use the same method without resource issues, I would think, but I'd suggest sticking with your ListView. Just display the basic information in the ListView and then when an item is selected, you can display the aditional information within a GroupBox underneath. Alternatively, you could open a seperate dialogue to display the details when an item is double-clicked.
 
my recamendation would be to use the list view with a groupbox at the bottom for when an item is selected
 
You can use whatever you want, but it comes down to what is the most productive implementation for you and for your user. If you like that interface then by all means implement it. I'd guess that it will be a bit more tricky than the alternatives, though. You'd want to be sure that the extra time and effort you spend on it will result in an interface that is "better" in some way. It is possible to get excited about the technology and simply do things because we can. I'm not making a judgement either way, but do weigh up your options.
 
What's to show? Set a Panel's AutoScroll property to True, then put a control on the Panel and set its Location such that it is outside the Panel's visible area. Voila! You have a Panel with scrollbars.
 
hello there
I have created the same list now and its working fine as well... But just one problem the
back color not changes as i wish or as it changes in Add/Remove Programs.

Im using the following code for changing back color
AddHandler objPanel.MouseEnter, AddressOf _ChangeBackColor

AddHandler objPanel.MouseLeave, AddressOf _ChangeBackColor2Normal

Private Sub _ChangeBackColor(ByVal e As System.Object, ByVal ev As System.EventArgs)

Try

e.BackColor = Color.PaleTurquoise

Catch ex As Exception

MsgBox(ex.Message)

End Try

End Sub

Private Sub _ChangeBackColor2Normal(ByVal e As System.Object, ByVal ev As System.EventArgs)

Try

e.BackColor = Color.White

Catch ex As Exception

MsgBox(ex.Message)

End Try

End Sub

Will you please explain why its happening.. What i guess is the panel do not have a focus property nor an event for this... so how to do it exactly like Add/Remove Programs List Background color change for Each Item in it....

Waiting for your reply

Regards
 
The Add/Remove Programs dialogue only changes colour when you click a section. If that's the behaviour you want, I'd recommend a single procedure to handle the Click event for all Panels. You know which Panel was clicked by the "sender" argument, so you iterate over all the Panels and set the BackColor of any that aren't the sender to the unselected color and the one that is to the selected colour. Here's a simple example:
VB.NET:
	Private Sub SetPanelColours(ByVal sender As Object, ByVal e As System.EventArgs)
		Dim selectedPanel As Panel = DirectCast(sender, Panel)
		Dim selectedBackColour As Color = SystemColors.Highlight
		Dim selectedForeColour As Color = SystemColors.HighlightText
		Dim unselectedBackColour As Color = SystemColors.Window
		Dim unselectedForeColour As Color = SystemColors.WindowText

		If selectedPanel.BackColor.Equals(unselectedBackColour) Then
			'A different panel was clicked.

			'Unselect the old panel.
			For Each ctl As Control In Me.Controls
				If TypeOf ctl Is Panel AndAlso _
				   Not ctl Is selectedPanel AndAlso _
				   ctl.BackColor.Equals(selectedBackColour) Then
				    'This control is the previously selected panel.
				    ctl.BackColor = unselectedBackColour
				    ctl.ForeColor = unselectedForeColour
					Exit For
				End If
			Next

			'Select the new panel.
			selectedPanel.BackColor = selectedBackColour
			selectedPanel.ForeColor = selectedForeColour
		End If
	End Sub
 
Well i tried it too but there is no reponse now... Please also let me know at which event add handler.. Currently im doing the following...
AddHandler objPanel.MouseEnter, AddressOf SetPanelColours

AddHandler objPanel.MouseLeave, AddressOf SetPanelColours

Please note that there is a loop which add panels on run time to main panel and the obove objPanel is created on runtime and added as well.

The code is same as you write just one modification at : Me.Controls --> Me.Controls.pnlMain.Controls

Thats because all panels are in this main panel..

Waiting for response


 
From my previous post:
jmcilhinney said:
The Add/Remove Programs dialogue only changes colour when you click a section. If that's the behaviour you want, I'd recommend a single procedure to handle the Click event for all Panels.
 
Well nothing good happening now...
The procudure is called on clicking as i have changed it to the objPanel.Click But it do not effect the state of any panel , i mean do not change the background color of any panel and by the way you might have seen that we can scroll through the panels by Key Up and Key Down and iterate through its controls by Tab in Add/Remove Programs.... Here i cant scroll up or down through Key Up and Key Down....

For instance i have check the value of :
selectedPanel.BackColor.Equals(unselectedBackColour) and it returns False thats why it do not evaluate the code further....

Im writing the following code after loop in the forms load event
' higlight the first panel...

Me.pnlMain.Controls(0).BackColor = SystemColors.Highlight

Me.pnlMain.Controls(0).ForeColor = SystemColors.HighlightText

waiting...........

 
Back
Top