Exemplo n.º 1
0
        private void LoadFiles(string[] files)
        {
            dataGridView1.Visible = true;
            dataGridView1.Columns.Clear();
            dataGridView1.AutoGenerateColumns           = true;
            dataGridView1.ColumnHeadersHeightSizeMode   = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            dataGridView1.RowsDefaultCellStyle.WrapMode = DataGridViewTriState.True;
            dataGridView1.RowTemplate = new DataGridViewRow();
            dataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells | DataGridViewAutoSizeColumnsMode.Fill);
            resources = new TextResourceCollection(files);
            dataGridView1.DataSource = resources;

            float fillWeight = (1F / (dataGridView1.Columns.Count + 1));

            foreach (DataGridViewColumn col in dataGridView1.Columns)
            {
                col.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                if (col.Name == "Name")
                {
                    col.FillWeight = fillWeight;
                    col.ReadOnly   = true;
                }
                else
                {
                    col.FillWeight = fillWeight;
                }
            }
        }
Exemplo n.º 2
0
        public Form1(string[] args)
        {
            resources = null;
            InitializeComponent();
            dataGridView1.Visible = false;
            if (args.Length > 0)
            {
                List <string> files = new List <string>();

                foreach (string file in args)
                {
                    if (File.Exists(file))
                    {
                        files.Add(file);
                    }
                }

                if (files.Count > 0)
                {
                    LoadFiles(files.ToArray());
                }
                else
                {
                    dataGridView1.Columns.Clear();
                }
            }
        }