A
anonieko
You can take a look at the DataGridViewColumn.Frozen property or the
DataGridViewBand class.
Example Code:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
DataSet ds = new DataSet();
ds.ReadXml("XMLFile1.xml");
dataGridView1.DataSource = ds.Tables[0];
FreezeBand(dataGridView1.Rows[0]);
FreezeBand(dataGridView1.Columns[0]);
}
private static void FreezeBand(DataGridViewBand band)
{
band.Frozen = true;
DataGridViewCellStyle style = new DataGridViewCellStyle();
style.BackColor = Color.SkyBlue;
band.DefaultCellStyle = style;
}
}
DataGridViewBand class.
Example Code:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
DataSet ds = new DataSet();
ds.ReadXml("XMLFile1.xml");
dataGridView1.DataSource = ds.Tables[0];
FreezeBand(dataGridView1.Rows[0]);
FreezeBand(dataGridView1.Columns[0]);
}
private static void FreezeBand(DataGridViewBand band)
{
band.Frozen = true;
DataGridViewCellStyle style = new DataGridViewCellStyle();
style.BackColor = Color.SkyBlue;
band.DefaultCellStyle = style;
}
}