Dernière mise à jour le 30/04/17

Présentation


Le but est de modifier l’aspect du tableau, comme vous pouvez le constater.



Programmation en C#



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics; 

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            dataGridView1.CurrentCell.Style.BackColor = Color.LightGreen;

        }

        private void button1_Click(object sender, EventArgs e)
        {

            dataGridView1.ColumnCount = 5;
            DataGridViewCellStyle style = dataGridView1.ColumnHeadersDefaultCellStyle;
            style.Font = new Font(dataGridView1.Font, FontStyle.Bold);
            
            dataGridView1.RowHeadersVisible = false; // modifie "l'aspect" du tableau en mettant True ou False 

            dataGridView1.Columns[0].Name = "Nom";
            dataGridView1.Columns[1].Name = "Prénom";
            dataGridView1.Columns[2].Name = "Age";
            dataGridView1.Columns[3].Name = "Domicile";
            dataGridView1.Columns[4].Name = "N° Tel";


            this.dataGridView1.DefaultCellStyle.ForeColor = Color.Black;

        }
         
    }
}

Prototype en vidéo


Non aucun

Historiques


30/04/17
– Première mise à disposition