回复 12楼qd98zhq的帖子
同样需要手动同步,代码如下:
- public MainWindow()
- {
- InitializeComponent();
- System.Data.DataRow dr = default(System.Data.DataRow);
- dt.Columns.Add("Series0");
- dt.Columns.Add("Series1");
- dr = dt.NewRow();
- dr[0] = 2;
- dr[1] = 1;
- dt.Rows.Add(dr);
- dr = dt.NewRow();
- dr[0] = 4;
- dr[1] = 2;
- dt.Rows.Add(dr);
- dr = dt.NewRow();
- dr[0] = 3;
- dr[1] = 4;
- gcSpreadSheet1.Sheets[0].AutoGenerateColumns = true;
- gcSpreadSheet1.Sheets[0].DataSource = dt;
- gcSpreadSheet1.Invalidate();
- gcSpreadSheet1.Sheets[0].CellChanged += MainWindow_CellChanged;
- }
- void MainWindow_CellChanged(object sender, GrapeCity.Windows.SpreadSheet.Data.CellChangedEventArgs e)
- {
- string text = this.gcSpreadSheet1.Sheets[0].Cells[e.Row, e.Column].Text;
- dt.Rows[e.Row][e.Column] = text;
- }
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- gcSpreadSheet1.Sheets[0].ReloadBindingData();
- gcSpreadSheet1.Invalidate();
- }
复制代码 |