先操作冻结功能->冻结成功->点击还原冻结功能->还原成功->继续冻结某一列->冻结成功->重新绑定原来的数据源->取消冻结列->还原失败。这时什么原理、详见代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using C1.Win.C1TrueDBGrid;
namespace C1Test
{
public partial class Form1 : Form
{
DataTable dt = new DataTable();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
InitTable();
c1TrueDBGrid1.DataSource = dt;
}
public void InitTable()
{
dt.Clear();
for (int i = 0; i < 10; i++)
{
dt.Columns.Add((i + 1).ToString(), typeof(string));
}
for (int j = 0; j < 4; j++)
{
DataRow dr = dt.NewRow();
for (int i = 0; i < 10; i++)
{
dr = (i + 1) + "" + (i + 1);
}
dt.Rows.Add(dr);
}
}
private void button1_Click(object sender, EventArgs e)
{
if (c1TrueDBGrid1.DataSource == null)
return;
c1TrueDBGrid1.Splits[0].DisplayColumns[2].Frozen = true;
}
private void button2_Click(object sender, EventArgs e)
{
c1TrueDBGrid1.DataSource = null;
c1TrueDBGrid1.DataMember = null;
//InitTable();
c1TrueDBGrid1.DataSource = dt;
}
private void button3_Click(object sender, EventArgs e)
{
foreach (C1DisplayColumn item in c1TrueDBGrid1.Splits[0].DisplayColumns)
{
item.Frozen = false;
}
}
}
}
|