Académique Documents
Professionnel Documents
Culture Documents
Địa chỉ: 6 Lê Lợi, Huế Điện thoại: 3823077 Fax: 3823649 Email: hue-aptech@huesoft.com.vn
b. The second form contains a Textbox, four command buttons, a ListView, a picturebox
and another controls, such as Figure 1.2
In this form:
• Textbox: allow entering path contain GIF images.
• OK: using when you change the path in the textbox, the first state of this button is
disabled. When the text had been change, it is enabled. And when you click in this
button images in Listview had been changed.
• Listview: display all images having in path which had been typed in textbox.
• PictureBox: display selected image in Listview.
• Textview, LargeView, SmallView button: used to change view state of listview.
• Close: to close this form.
Hints:
- Function to get all GIF images:
public static void loadForm(string path, ImageList imgl, ListView l){
DirectoryInfo thisfolder= new DirectoryInfo(@path);
object[] images=thisfolder.GetFiles("*.GIF");
int i=0;
imgl.Images.Clear();
foreach(object s in images)
{
string file= path +"\\" + s.ToString();
imgl.Images.Add(new System.Drawing.Bitmap(@file));
l.Items.Add(s.ToString(),i);
i++;
}
}
- Event handler SelectIndex change
lstImages: is a ListView control in this form
picImage: is a PictureBox control in this form
txtFolder: is a TextBox control in this form
private void lstImages_SelectedIndexChanged(object sender, System.EventArgs e)
{
foreach(ListViewItem o in lstImages.SelectedItems){
string file= txtFolder.Text +"\\" + o.Text;
Image img= new System.Drawing.Bitmap(@file);
picImage.Image= img;
lstImages.Select();
}
2. Create a window application such as exercise 1, but in the second form using TreeView
to replace Textbox and OK button. TreeView should allow selected folder which contains
GIF images.