1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace compone
{
public partial class Form1 : Form
{
string fil; string[] files;
public Form1()
{
InitializeComponent();
}
private void ad_Click(object sender, EventArgs e)
{
if (of.ShowDialog() == DialogResult.Cancel)
return;
else
{
string []files=of.FileNames ;
foreach (string fil in files)
{
ListViewItem mic = new ListViewItem(fil);
FileInfo tm0 = new FileInfo(fil);
listView1.Items.Add (""+mic,""+tm0.Extension,""+tm0.Length );
}
}
}
private void mod_Click(object sender, EventArgs e)
{
//Sert à modifier l'élément selectionnné mais ne fonctionne pas!!!
try
{
listView1.Items[SelectedIndex] = fil;
}
catch (Exception tm)
{
MessageBox.Show(tm.Message);
}
}
private void sup_Click(object sender, EventArgs e)
{
listView1.Items.RemoveAt(listView1.SelectedIndex);
}
private void slf_Click(object sender, EventArgs e)
{
try
{
FolderBrowserDialog mic = new FolderBrowserDialog();
mic.ShowDialog();
listView1.Items.Add(mic.SelectedPath);
}
catch (Exception m)
{
MessageBox.Show(m.Message);
}
}
private void Form1_Load(object sender, EventArgs e)
{
sup.BackColor = Color.Beige;
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (MessageBox.Show("Voulez-vous vraiment fermer ?", "Confirmation", MessageBoxButtons.OKCancel,MessageBoxIcon.Question) == DialogResult.Cancel)
{
e.Cancel = true;
}
}
private void qt_MouseHover(object sender, EventArgs e)
{
ToolTip tm = new ToolTip();
tm.SetToolTip(qt, "Ceci est mon controle préféré!");
}
private void qt_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
} |
Partager