winform spread 15.0 SheetView绑定Models.Data = model后,designer中设置的列标题失效
这个是静态画面
执行完spread_Sheet1.Models.Data = model;
designer.cs文件中对表格的属性设置全被清空,有什么好的解决办法吗?
列标题没有了
主画面
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
private MTGA0010MeisaiSheetDataModel model;
/// <summary>
///
/// </summary>
List<DataRow> hanyoKanriRecordDetail;
public DataTable HanyoKanriRecordDetail
{
set
{
hanyoKanriRecordDetail = new List<DataRow>();
if (value != null)
{
hanyoKanriRecordDetail.AddRange(value.AsEnumerable().ToList());
}
//RefreshList();
}
}
public Form1()
{
model = new MTGA0010MeisaiSheetDataModel();
//model = new FarPoint.Win.Spread.Model();
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// SPREAD初期化处理
spread_Sheet1.Models.Data = model;
}
}
}
MTGA0010MeisaiSheetDataModel.cs
namespace MTGA0010.DataModel
{
/// <summary>
/// SPREAD SheetDataModel
/// </summary>
public class MTGA0010MeisaiSheetDataModel : BaseSheetDataModel
{
/// <summary>
///
/// </summary>
List<DataRow> hanyoKanriRecordDetail;
/// <summary>
///
/// </summary>
private bool readOnly;
/// <summary>
///
/// </summary>
private List<Func<int, object>> columns = new List<Func<int, object>>();
/// <summary>
///
/// </summary>
public bool ReadOnly
{
get { return readOnly; }
set
{
readOnly = value;
if (hanyoKanriRecordDetail != null)
{
RefreshList();
}
}
}
/// <summary>
///
/// </summary>
public void RefreshList()
{
OnChanged(new SheetDataModelEventArgs(-1, -1,
this.RowCount, this.ColumnCount, SheetDataModelEventType.ModelUpdated));
}
/// <summary>
///
/// </summary>
public DataTable HanyoKanriRecordDetail
{
set
{
hanyoKanriRecordDetail = new List<DataRow>();
if (value != null)
{
hanyoKanriRecordDetail.AddRange(value.AsEnumerable().ToList());
}
RefreshList();
}
}
/// <summary>
///
/// </summary>
public MTGA0010MeisaiSheetDataModel()
{
this.hanyoKanriRecordDetail = null;
this.hanyoKanriRecordDetail = new List<DataRow>();
SetColumn();
}
/// <summary>
///
/// </summary>
public override int RowCount
{
get
{
if (hanyoKanriRecordDetail == null)
{
return 0;
}
return this.hanyoKanriRecordDetail.Count;
}
}
/// <summary>
///
/// </summary>
public override int ColumnCount
{
get
{
return columns.Count;
}
}
/// <summary>
///
/// </summary>
private void SetColumn()
{
Func<int, Class1> f = r => new Class1(hanyoKanriRecordDetail[r]);
columns.Add((r) => f(r).GetString("HAK_KANRI_KBN"));
columns.Add((r) => f(r).GetString("HAK_MEISAI_KBN"));
columns.Add((r) => f(r).GetString("HAK_MEISAI_NM"));
columns.Add((r) => f(r).GetDate("HAK_INSERT_DATE"));
columns.Add((r) => f(r).GetString("HAK_INSERT_USER"));
columns.Add((r) => f(r).GetDate("HAK_UPDATE_DATE"));
columns.Add((r) => f(r).GetString("HAK_UPDATE_USER"));
}
/// <summary>
///
/// </summary>
public void SetDetailData()
{
RefreshList();
}
/// <summary>
///
/// </summary>
/// <param name="rowNumber"></param>
/// <returns></returns>
public DataRow GetDetailRow(int rowNumber)
{
return hanyoKanriRecordDetail[rowNumber];
}
/// <summary>
///
/// </summary>
/// <param name="row"></param>
public void AddDetailData(DataRow row)
{
hanyoKanriRecordDetail.Add(row);
RefreshList();
}
/// <summary>
///
///
/// </summary>
/// <param name="row"></param>
/// <param name="column"></param>
/// <returns></returns>
public override object GetValue(int row, int column)
{
object fieldData = "";
fieldData = columns[column](row);
return fieldData;
}
/// <summary>
///
/// </summary>
/// <param name="row"></param>
/// <param name="column"></param>
/// <param name="value"></param>
public override void SetValue(int row, int column, object value)
{
base.SetValue(row, column, value);
switch (column)
{
case 0:
DataRow dr = hanyoKanriRecordDetail[row];
dr["UPDATE_STATUS"] = (bool)value ? 3 : 2;
break;
}
}
}
}
|
|