using FarPoint.Win;
using FarPoint.Win.Spread;
using FarPoint.Win.Spread.CellType;
using FarPoint.Win.Spread.Model;
using GrapeCity.CalcEngine;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;

namespace spread_win_richtextbox
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            txtSpread_Recd.Attach(fpSpread1);
            formulaTextBox.Attach(fpSpread1);
        }

  
        private void Form1_Load(object sender, EventArgs e)
        {
            fpSpread1.Open(AppDomain.CurrentDomain.BaseDirectory + "6.xml");
            for (int i = 0; i < fpSpread1.Sheets.Count; i++)
            {
                fpSpread1.Sheets[i].Models.Data.Changed += Data_Changed;
                fpSpread1.Sheets[i].CellChanged += Form1_CellChanged;
            }
        }

        private void Form1_CellChanged(object sender, SheetViewEventArgs e)
        {
            MessageBox.Show("CellChanged：" + e.Row + ",列" + e.Column + "值:" + fpSpread1.ActiveSheet.GetText(e.Row, e.Column).ToString());
        }

        private void Data_Changed(object sender, FarPoint.Win.Spread.Model.SheetDataModelEventArgs e)
        {
            var sv = (DefaultSheetDataModel)sender;           
            MessageBox.Show("Data_Changed：" + e.Row + "," + e.Column + "值:" + sv.GetValue(e.Row, e.Column).ToString());
        }
        

        private void fpSpread1_Change(object sender, ChangeEventArgs e)
        {
            MessageBox.Show("Change：" + e.Row + "," + e.Column + "值:" + fpSpread1.ActiveSheet.GetText(e.Row, e.Column).ToString());
        }

        private void fpSpread1_EditChange(object sender, EditorNotifyEventArgs e)
        {
            MessageBox.Show("EditChange：" + e.Row + "," + e.Column + "值:" + fpSpread1.ActiveSheet.GetText(e.Row, e.Column).ToString());
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            fpSpread1.Sheets[0].SetValue(6, 1, 10);
        }
        private void button3_Click(object sender, EventArgs e)
        {
            fpSpread1.AllowDragFill = true;
            fpSpreadDesigner.ShowDialog(fpSpread1);
        }
    }
}
