Using the ListView control to display a data 01.ImageList control
1. Learn About
Property |
Description |
Images |
All images stored in the image list |
ImageSize |
The size of the image in the image list |
Transparent |
Colors that are considered transparent |
ColorDepth |
Gets the color depth of the image list |
Images The image is stored in the same way as in an array, the Count property allows you to get the number of images in the images. Each image has an index value, starting at 0, using the images[index value], to navigate to an image.
The ImageList control contains images that can be used by Listview,treeview,toolstrip controls.
2. Using the ImageList control
steps:
in the Toolbox, locate the ImageList control, and double-click Add. But the ImageList control does not appear on the form, but instead appears underneath the form.
Please select the "ImageList" control, click "Select Image" to open the "Image Collection Editor"
Then click Add to add the desired picture one by one. Click "OK"
Note: 1. The image size is the size of the picture you want to select.
2. The best image bit depth is the maximum value.
03. You can use the ListView and ImageList. (I'll start with that)
02.ListView Controls and Coutextmenustrip (right-click) controls
The results can be achieved:
One: Use the ListView step:
in the Toolbox, locate the ListView control, and double-click Add.
Select Edit Item. Add items to the view (default values for the form display after selection), small ImageList, large ImageList Select corresponding values
It is often necessary to assign values: Text (the name of the item), ImageIndex (the diagram to be used),
If you want to make "details", you should continue in the subitem (subkey).
Two: Using the Coutextmenustrip (right-click) control
in the Toolbox, locate the Coutextmenustrip control, and double-click Add. But the Coutextmenustrip control does not appear on the form, but instead appears underneath the form.
Edit each value.
last point, a lot of classmates forget to get associated with the ListView control (name:), which is the ContextMenuStrip property
Three: Everything is ready, just put all the functions and buttons associated with it! Let's take a look at:
private void Button_big_click ( Span style= "color: #0000ff;" >object sender, EventArgs e) {lview.view = View.LargeIcon; private void Button_small_ Click (object sender, EventArgs e) {L View.view = View.SmallIcon; private void Button_details_ Click (object sender, EventArgs e) {L View.view = View.Details; }
Isn't it simple? But if we can only use the code to achieve "detailed information" is good, to everyone:
First of all, let's start with the column values.
The code is then available:
Private voidForm1_Load (Objectsender, EventArgs e) {ListViewItem ListView=NewListViewItem ("a plate",0); LISTVIEW.SUBITEMS.ADD ("Local Disk"); LISTVIEW.SUBITEMS.ADD ("100GB"); LISTVIEW.SUBITEMS.ADD ("10GB"); Lvlist. Items.Add (ListView); ListViewItem ListView1=NewListViewItem ("B-Plate",1); LISTVIEW1.SUBITEMS.ADD ("Local Disk"); LISTVIEW1.SUBITEMS.ADD ("200GB"); LISTVIEW1.SUBITEMS.ADD ("20GB"); Lvlist. Items.Add (LISTVIEW1); ListViewItem ListView2=NewListViewItem ("C-Plate",2); LISTVIEW2.SUBITEMS.ADD ("Local Disk"); LISTVIEW2.SUBITEMS.ADD ("300GB"); LISTVIEW2.SUBITEMS.ADD ("30GB"); Lvlist. Items.Add (LISTVIEW2); }
It's all right! It's not as hard as you think! Try it slowly, and you'll feel it's charm.
Windows program ==>> using the ListView control to display data