DataGridView Nesnesinde Sütun Gizlemek
Merhaba arkadaşlar. Bu makalemizde Datagridview nesnesinde Ad sütununu gizleyeceğiz.
Form1.cs
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;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
dataGridView1.ColumnCount = 5;
dataGridView1.Columns[0].Name = "Id";
dataGridView1.Columns[1].Name = "Ad";
dataGridView1.Columns[2].Name = "Soyad";
dataGridView1.Columns[3].Name = "Kısım";
dataGridView1.Columns[4].Name = "Mail";
string[] satir = new string[] { "1", "Bahadır", "Şahin", "Arge","bahadir@hotmail.com" };
dataGridView1.Rows.Add(satir);
satir = new string[] { "2", "Fatih", "Koç", "Arge", "fatih@hotmail.com" };
dataGridView1.Rows.Add(satir);
satir = new string[] { "3", "Haluk", "Akman", "Arge", "haluk@hotmail.com" };
dataGridView1.Rows.Add(satir);
satir = new string[] { "4", "Mesut", "Alp", "Arge", "mesut@hotmail.com" };
dataGridView1.Rows.Add(satir);
satir = new string[] { "5", "Adem", "Cenk", "Arge", "adem@hotmail.com"
};
dataGridView1.Rows.Add(satir);
}
private void button1_Click(object sender, EventArgs e)
{
//Sütunu
gizliyoruz.
dataGridView1.Columns[1].Visible = false;
}
}
}
Bir makalenin daha sonuna geldik. Bir sonraki makalede
görüşmek üzere. Bahadır ŞAHİN