回复 12楼swejet的帖子
可以通过行列索引控制,测试代码如下:
- class MyDrawingObjectProvider : IDrawingObjectProvider
- {
- public DrawingObject[] GetDrawingObjects(Worksheet sheet, int row, int column, int rowCount, int columnCount)
- {
- DrawingObject dobj;
- ComboBox control = new ComboBox();
- if (row==1&&column==1)
- {
- int value = -1;
- object obj = sheet.GetValue(row, column);
- if (obj != null)
- {
- if (obj is int) value = (int)obj;
- else
- {
- int.TryParse(obj.ToString(), out value);
- }
- if (value > 2) value = -1;
- }
- control.Items.Add("Fruit");
- control.Items.Add("Vegetable");
- control.Items.Add("Food");
- if (value >= -1 && value < control.Items.Count)
- control.SelectedIndex = value;
- control.SelectionChanged += delegate(object sender, SelectionChangedEventArgs e)
- {
- sheet.SetValue(row, column, control.SelectedIndex);
- };
- dobj = new ControlDrawingObject(row, column, control);
- return new DrawingObject[] { dobj };
- }
- else
- {
- return null;
- }
- }
- }
复制代码 |