GcSpreadSheet问题
求助: GcSpreadSheet里的单元格(cell)或某列不能设置为combobox类型的吗? 回复 1楼zjutwb的帖子实现方法请参考链接:
http://blog.gcpowertools.com.cn/post/2014/12/30/hyperlink-cell-in-spread-silverlight.aspx 问题是解决了,但是,出现了两种情况,前面的combobox能否像后面的这个样子呢?
而且,combobox都一直显示在,是否能像后面的这个类型,只有点击的时候才显示? 回复 4楼zjutwb的帖子
第二种是 Spread 提供的 Validate 方法:
gcSpreadSheet1.HighlightInvalidData = true;
var valid = GrapeCity.Windows.SpreadSheet.Data.DataValidator.CreateListValidator("5,10,15,20");
gcSpreadSheet1.Sheets.Cells.DataValidator = valid;
Validate 方法有没有办法提供像combobox的功能?比如选项有值和显示值。 回复 6楼zjutwb的帖子
zjutwb
如果要实现“选项有值和显示值”的需求,还是需要通过重写GetDrawingObject来实现,我创建了一个测试的WPF工程,你可以先看看是否是你需要的功能:
public partial class MainWindow : Window
{
private CellRange activeCell = null;
public MainWindow()
{
InitializeComponent();
MyWorksheet sheet = new MyWorksheet();
this.gcSpreadSheet1.Sheets.Clear();
this.gcSpreadSheet1.Sheets.Add(sheet);
activeCell = new CellRange(this.gcSpreadSheet1.ActiveSheet.ActiveRowIndex, this.gcSpreadSheet1.ActiveSheet.ActiveColumnIndex, 1, 1);
this.gcSpreadSheet1.ActiveSheet.PropertyChanged += ActiveSheet_PropertyChanged;
}
void ActiveSheet_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == "ActiveCell")
{
this.gcSpreadSheet1.InvalidateRange(activeCell.Row, activeCell.Column, 1, 1);
activeCell = new CellRange(this.gcSpreadSheet1.ActiveSheet.ActiveRowIndex, this.gcSpreadSheet1.ActiveSheet.ActiveColumnIndex, 1, 1);
this.gcSpreadSheet1.InvalidateRange(activeCell.Row, activeCell.Column, 1, 1);
}
}
}
public class ControlDrawingObject : CustomDrawingObject
{
private Control _rootElement;
public ControlDrawingObject(int row, int col, Control control) : base(row, col) { _rootElement = control; this.ShowDrawingObjectOnly = true; }
public override FrameworkElement RootElement
{
get { _rootElement.Margin = new Thickness(1); return _rootElement; }
}
}
public class MyWorksheet : Worksheet
{
public bool DrawingObjectVisible { get; set; }
public override DrawingObject[] GetDrawingObject(int row, int column, int rowCount, int columnCount)
{
if (column == 1 && row == this.ActiveRowIndex && column == this.ActiveColumnIndex)
{
DrawingObject dobj;
dobj = new ControlDrawingObject(row, column, new ComboBox());
return new DrawingObject[] { dobj };
}
else
{
return base.GetDrawingObject(row, column, rowCount, columnCount);
}
}
} 7#,你的这个挺好。可惜,函数不熟悉,悲剧 回复 8楼zjutwb的帖子
在 7# 中的示例程序能满足你的需求吗? 基本满足,但还得修改下,谢谢了。
页:
[1]
2