大家可以在表单插件EntityBlockPasting事件中自己处理,然后将cancel设置为true。以下代码可以参考一下,插件代码中需要将其中一些属性或方法修改,例如this.BusinessInfo替换为this.View.BusinessInfo,UpdateValue替换为this.View.Model.SetValue,this.StyleManager替换为((IDynamicFormView)this.View).StyleManager

        /// <summary>
/// 块拷贝
/// </summary>
/// <param name="startKey"></param>
/// <param name="startRow"></param>
/// <param name="blockValue"></param>
public void EntityBlockPasting(string startKey, int startRow, string blockValue)
{
if (!blockValue.IsNullOrEmptyOrWhiteSpace())
{
EntityBlockPastingEventArgs args = new EntityBlockPastingEventArgs(startKey, startRow, blockValue);
this.EventsProxy.FireEntityBlockPasting(args);
if (args.Cancel)
{
return;
}
Field fd = this.BusinessInfo.GetField(startKey);
if (fd == null) return;
int entityRowCount = this.Model.GetEntryRowCount(fd.EntityKey);
string[] rowValues = blockValue.Split('\n');
int blockRowCount = rowValues.Length-1;
if (blockRowCount > entityRowCount)
{
// 当前实体行数不足,补齐行数据
for (int i = entityRowCount; i < blockRowCount; i++)
{
this.Model.CreateNewEntryRow(fd.EntityKey);
}
}
Dictionary<int, string> fieldKeyList = new Dictionary<int, string>();
int row = startRow;
foreach (string strValue in rowValues)
{
if (strValue.IsNullOrEmpty())
{
// 最后空行结束
return;
}
string[] strs = strValue.Split('\t');
int fieldCount = strs.Length;
SetFieldKeyList(startKey, fd, fieldKeyList);
if (fieldKeyList.Count == 0)
{
// 可能找不到列,则返回
return;
}
int index = 0;
foreach (string str in strs)
{
string key = fieldKeyList[index];
// 未锁定状态下更新数据,锁定跳过
if (this.StyleManager.GetEnabled(this.LayoutInfo.GetFieldAppearance(key)))
{
this.UpdateValue(fieldKeyList[index], row, str);
}
index++;
}
row++;
}
}
}
private void SetFieldKeyList(string startKey, Field fd, Dictionary<int, string> fieldKeyList)
{
if (fieldKeyList.Count > 0)
{
return;
}
int start = 0;
List<Field> fields = new List<Field>();
fields.AddRange(fd.Entity.Fields);
fields.Sort(new Comparison<Field>((x, y) =>
{
return x.Tabindex.CompareTo(y.Tabindex);
}));
foreach (Field f in fields)
{
if (startKey.EqualsIgnoreCase(f.Key))
{
fieldKeyList[start++] = f.Key;
continue;
}
if (start > 0)
{
// 可见的列才被用来粘贴
if (this.StyleManager.GetVisible(this.LayoutInfo.GetFieldAppearance(f.Key)))
{
fieldKeyList[start++] = f.Key;
continue;
}
}
}
}

最新文章

  1. todo
  2. 关于HttpURLConnection.setFollowRedirects
  3. 虚幻4外包团队-推荐非常全面的的Unreal教程
  4. 自动验证是ThinkPHP
  5. mysql 数据库怎样快速的复制表以及表中的数据
  6. cURL和HTTPie
  7. C# 仿迅雷风格选项卡
  8. 001_python变量命名规范(待实践一遍)
  9. Qt入门(3)——信号和槽
  10. poj2187 Beauty Contest(旋转卡壳)
  11. Java 中的resultset详解
  12. 虚拟主机VPS区别:DigitalOcean优惠码
  13. nodejs的简单爬虫
  14. GIT入门笔记(15)- 链接到私有GitLab仓库
  15. Coding and Paper Letter(五十八)
  16. 逻辑卷(lv)管理(LVM)
  17. JAVA 图形界面开发基础详解
  18. ASP入门(二十三)- 数据库插入、更新和删除操作
  19. webstorm 2017 激活破解
  20. HtmlImageGenerator字体乱码问题解决、html2image放linux上乱码问题解决

热门文章

  1. [转]java注解与APT技术
  2. CF622C Not Equal on a Segment
  3. postgresql版sde(10.4.1)安装说明
  4. 让WPS10显示为offic97效果
  5. JD IPO address by liuqiangdong
  6. Halcon学习笔记2
  7. Hessian矩阵与牛顿法
  8. Zotero文献管理神器使用
  9. C语言常用关键字及运算符操作---关键字
  10. 【转】解决WPF图片模糊最佳方法(绑定PixelWidth与PixelHeight)