Spread for WinForms 表格控件客户问题实战_第1页
Spread for WinForms 表格控件客户问题实战_第2页
Spread for WinForms 表格控件客户问题实战_第3页
Spread for WinForms 表格控件客户问题实战_第4页
Spread for WinForms 表格控件客户问题实战_第5页
已阅读5页,还剩75页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

产品网站: 1 of 80 表格控件 客户问题实战 产品网站: 2 of 80 目录 1. 安装 Spread for WinForms . 4 2. 添加 Spread 控件到 Microsoft Visual Studio 工具箱 . 4 3. 激活 Spread for WinForms 表格控件 . 4 4. 部署 . 6 5. 升级产品 . 8 6. 单元格类型 . 8 7. 单元格交互 . 22 8. 边框及网格线设置 . 27 9. 行列交互 . 33 10. 表单交互 . 36 11. 排序 . 39 12. 过滤 . 41 13. 数据搜索 . 42 14. 数据绑定 . 43 15. 数据可视化 . 46 图表 . 46 Shape . 52 波形图 . 55 条件格式化 . 57 16. 大纲分组 . 57 17. Outlook 分组 . 58 18. 级联显示 . 60 19. 公式 . 61 20. 打印 . 65 21. 键盘动作映射 . 67 产品网站: 3 of 80 22. 剪切板操作 . 68 23. 鼠标交互 . 69 24. 文件交互 . 72 Excel 导出 . 72 Excel 导入 . 75 25. 皮肤 . 76 26. 如何调用设计器 . 78 27. 汉化 . 79 28. 本文档所有示例下载地址 . 80 产品网站: 4 of 80 1. 安装 Spread for WinForms 安装 Spread for WinForms 产品步骤 如下: 1) 保存下载的 ZIP 文件到临时目录,解压该文件到临时目录。 2) 如 已经 安装试用版或旧版本,运行该版本控件的安装文件并按照提示进行卸载 (卸载 前请通过 LicenseManager 反 激活) ,否则进行第 4 步。 3) 重新打开安装文件夹。 4) 运行 SpreadWin(Bits 控件 安装包 ) 或 SpreadWin(Docs 文档 安装包 )。 5) 点击欢迎界面的 下一步 。 6) 在许可协议界面上,选择是否同意协议,若同意,点击 下一步 。 7) 选择需要安装 的 控件, 点击 下一步 : 8) 继续执行安装步骤, 直至 点击 “ 完成 ” 按钮 确认安装完成。 注意: 如果 安装 系统为 Microsoft Windows Vista 或更高版本 , 你需要使用 管理员权限安装 。如果 仍然无法安装 ,请 尝试请 禁用使用者帐户控 制 (UAC) 后 再次安装。 Spread for WinForms: Microsoft 已经告知 MSN Messenger 会 锁定 GAC, 这样就会阻止安装程序移除 GAC 中的旧版本程序集。 2. 添加 Spread 控件 到 Microsoft Visual Studio 工具箱 在 Microsoft Visual Studio 使用 Spread 表格控件 , 你需要添加 控件到 工具箱,操作步骤如下: 1) 如果工具箱 没有显示 ,在 Visual Studio 视图 菜单中选择 “工具箱” 。 2) 右键 点击工具箱,在弹出的菜单项中 点击 “选择项” 选项。 3) 在选择 工具箱对话框中 , 选择 “.NET Framework 组件 ” 选项卡 。 4) 在 “.NET Framework 组件 ” 选项卡 中, Spread 控件( FarPoint.Win.Spread 命名空间 ) 应该已经在列表中。 5) 勾选 FpSpread 控件点击 “确认” 按钮。 6) 如果 Spread 表格 控件没有显示在列表中,点击 “ 浏览 ” 按钮,在安装文件夹下选择FarPoint.Win.Spread.dll 后 点击打开 。 这时 Spread 表格 控件被添加到列表中 , 勾选后点击 “确认” 按钮 。 3. 激活 Spread for WinForms 表格 控件 可以 通过以下步骤激活 Spread 表格 控件: 1) 运行 葡萄城许可证管理工具 (开始 菜单 -所有 程序 -ComponentOne-License Manager) 。 产品网站: 5 of 80 2) 在弹出 的界面上 点击 “ 激活 ” 链接。 3) 激活 产品建的界面上点击 “ 下一步 ” 。 4) 在输入 产品键界面输入 产品键 等使用信息 点击“ 下一步 ” 按钮。 产品网站: 6 of 80 5) 激活 成功界面点击 “完成” 按钮确认激活完毕。 4. 部署 系统要 求 您的系统必须满足以下配置要求: Microsoft Windows 98 Microsoft Windows 98 SE Microsoft Windows ME Microsoft Windows 2000 (SP3) Microsoft Windows Server 2003 Microsoft Windows Server 2008 Microsoft Windows XP (SP2) Microsoft Windows Vista Microsoft Windows 7 Microsoft Windows 8 软件 要求 必须安装 Microsoft .NET 平台。 产品网站: 7 of 80 部署文 件 您必须在用户系统中部署下列文件: 下列程序集是与 Spread for Windows Forms 一起提供的: FarPoint.CalcEngine.dll FarPoint.Excel.dll FarPoint.PluginCalendar.WinForms.dll FarPoint.Win.dll FarPoint.Win.Spread.dll FarPoint.Localization.dll 安装应用程序必须从 Spread for Windows Forms 目录复制这些程序集到应用程序的可执行文件目录下或者把他们安装到全局程序集缓存中 (GAC)。了解 GAC 信息,请参照 Microsoft Visual Studio .NET 和 .NET 平台文档。 .NET 平台可在发行组件包,如果用户系统上没有 .NET 平台,关于软件包的更多信息,参照 .NET平台文档。 如果您要使用高级 ink 您需要同时部署 FarPoint.Win.Ink.dll。这些程序集到应用程序的可执行文件目录下或者把他们安装到全局程序集缓存中 (GAC)。这也需要 Microsoft Tablet PC SDK 运行是组件。 FarPoint.Win.Ink 程序集是基于 Microsoft Tablet PC SDK 1.7 版本编译的。 如果在您的工程中应用了文本编辑器功能那么您需要部署 FarPoint.Win.TextRenderer.dll。这个 DLL 需要和应用程序的可执行文件安装在统一文件夹下。这个特性只在 .NET 2.0 平台下使用。 如果在您的工程中应用了导出 PDF 格式的功能那么您同样需要部署 FarPoint.PDF.dll。 如果在您的工程中应用了导出 HTML 格式的功能那么您需要同时部署FarPoint.Win.Spread.Html.dll 和 System.Web.dll。 如果在运行时使用了 Spread 设计器那么您需要部署 FarPoint.Win.Spread.Design.dll。 如果在您的工程中应用了图表控件您需要部署 FarPoint.Win.Chart.dll。 如果 在您的工程中应用了 GcTextBox 或 GcDateTime 您需要 部署 GrapeCity.Win.PluginInputMan.dll。 托管网页上的控 制 如果您将 Spread for Windows Forms 控件作为用户控件托管在 Microsoft Internet Explorer (IE) 一个网页上,调整下列安全权限: 在 IE 中,选择工具 -Internet 选项 -安全并选择可信任站点。点击网站按钮并添加网站 (例如 http:/localhost)。 产品网站: 8 of 80 在 Windows 中,选择开始 -设置 -控制面板并选择管理工具。选择 Microsoft .NET 框架配置。在 .NET 平台配置窗体,选择运行库安全策略并点击调整区域安全。 5. 升级产品 升级 Visual Studio .NET 工具箱 对于 新的工程 ,您需要 移除工具箱中的现有 Spread 控件,再 添加新的 Spread 控件。 1) 如果工具箱 没有显示 ,在 Visual Studio 视图 菜单中选择 “工具箱 ” 。 2) 右键 点击工具箱,在弹出的菜单项中 点击“选择项 ” 选项。 3) 在选择 工具箱对话框中 , 选择 “.NET Framework 组件 ” 选项卡 。 4) 在 “.NET Framework 组件 ” 选项卡 中, Spread 控件( FarPoint.Win.Spread 命名空间 ) 应该 已经在列表中。 5) 勾选 FpSpread 控件点击 “ 确认 ” 按钮。 6) 如果 Spread 表格 控件没有显示在列表中,点击 “ 浏览 ” 按钮,在安装文件夹下选择FarPoint.Win.Spread.dll 后 点击打开 。 这时 Spread 表格 控件被添加到列表中 , 勾选后点击“ 确认 按钮 ” 。 升级现有 Visual Studio.NET 工程 1) 对于现有的 工程 , 升级步骤如下: 2) 删除使用了 Spread 工程中 Spread 相关的 DLL 引用 3) 删除使用了 Spread 的工程中 licenses.licx 文件 4) 在工程中添加一个新的窗体(为了自动生成 Licenses.licx,并自动添加 Spread 相关的 DLL 引用) 5) 在 VS 工具箱中将 Spread 控件添加到窗体中,此时会自动添加 Spread 相关的 DLL 引用,并自动 生成 licenses.licx 文件(需要确认 DLL 和 License 中 Spread 的版本号是否正确) 6) 对解决方案中所有工程进行 1-4 步操作 。(一般客户会在该步骤出现问题,一定要针对项目的所有工程进行操作) 7) Rebuild 整个解决方案。 8) 重新发布。 6. 单元格类型 本章节 中将列举 了 Spread 用户在实际项目中遇到的 典型 单元格类型问题, 包括 了 常用 单元格 类型 的设置方法 、 事件 捕获 及 扩展 现有单元格类型实现 自定义 单元格类型 等 。 Spread 支持多达 24 种 单元格类型。设置单元格类型时,对每一种单元格类型,您需要创建一个单元格类型对象,设置其属性,然后将其设为一个或多个单元格的 CellType 属性。 产品网站: 9 of 80 单元格 类型 指定 了 用户与单元格交互的形式,通过指定的单元格 类型 对数据进行访问,显示,校验。单元格类型为单元格定义了一个 editor 用以处理输入数据 ,一个 formatter 用以分析数据,还有一个 render 用以控制单元格的数据如何显示。 ComboxCellType 不同 选项 定制 不同的背景色 问题描述 :如何获取 ComoboCellType 的 选择事件,改变单元格的背景色。 问题 解答: ComoboCellType 提供 了 EditorValueChanged 事件 用于捕获选择事件。 关键代码 : 添加 ComboCellType 单元格 类型 通过 事件判断选择文本更改背景色: 效果截图 : / /添加 ComboBoxCellType 单元格类型 / private void AddCellType() FarPoint.Win.Spread.CellType.ComboBoxCellType comboBoxCellType1 = new FarPoint.Win.Spread.CellType.ComboBoxCellType(); comboBoxCellType1.Items = (newString 红色 , 绿色 , ); fpSpread1.Sheets0.Cells0, 0.CellType = comboBoxCellType1; comboBoxCellType1.EditorValueChanged += newEventHandler(comboBoxCellType1_EditorValueChanged); void comboBoxCellType1_EditorValueChanged(object sender, EventArgs e) FarPoint.Win.Spread.CellType.ComboBoxCellType test = sender as FarPoint.Win.Spread.CellType.ComboBoxCellType; if (this.fpSpread1.Sheets0.ActiveCell.Text = 红色 ) this.fpSpread1.Sheets0.ActiveCell.BackColor = Color.Red; if (this.fpSpread1.Sheets0.ActiveCell.Text = 绿色 ) this.fpSpread1.Sheets0.ActiveCell.BackColor = Color.Green; 产品网站: 10 of 80 示例下载: 点击下载 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 如何禁止 ComboxCellType 编辑 问题描述 : 如何 设置 ComboCellType 所在 单元格只能 通过 选择项更改文本, 禁止通过 键盘编辑文本。 问题 解答: ComboCellType 提供了 Editable 属性 用于获取或设置是否 可以 编辑 文本。 关键代码 : 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 / /添加 ComboCellType 并且禁止编辑 / private void AddCellType() string cbstr; cbstr = newString AAA, AABC, ABBC, BBB, BBC, BCC ; string strval; strval = newString 1, 2, 3, 4, 5, 6 ; FarPoint.Win.Spread.CellType.ComboBoxCellType combo = new FarPoint.Win.Spread.CellType.ComboBoxCellType(); combo.Items = cbstr; combo.ItemData = strval; combo.EditorValue = FarPoint.Win.Spread.CellType.EditorValue.ItemData; /禁止编辑 Combo 文本 combo.Editable = false; fpSpread1.Sheets0.Cells0, 0.CellType = combo; 产品网站: 11 of 80 实现像 google 搜索 一样的自动完成功能 问题描述 : 通过 输入字符在 自动 匹配 数据库 中选项 , 提高输入效率。 问题 解答: ComboBoxCellType 提供了 AutoCompleteMode 属性 用于设置 自动 完成模式,AutoCompleteSource 用于 指定自动完成数据源。 关键代码 : 示例下载: 点击下载 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 如何 在单元格中同时显示文本和图片 问题描述 : 希望 在单元格中同时添加文本和图片混排 的 方式。 问题 解答: Spread 提供了 单元格自定义功能,可以继承 ComoboCellType 并且 重载 PaintCell 方法 来手动 添加 图片。 关键代码 : /设置单元格类型 FarPoint.Win.Spread.CellType.ComboBoxCellType combo = new FarPoint.Win.Spread.CellType.ComboBoxCellType(); string cbstr; cbstr = newString AAA, AABC, ABBC, BBB, BBC, BCC ; string strval; strval = newString 1, 2, 3, 4, 5, 6 ; combo.Items = cbstr; combo.ItemData = strval; combo.EditorValue = FarPoint.Win.Spread.CellType.EditorValue.ItemData; /指定自动完成的模式及数据源 combo.AutoCompleteMode = AutoCompleteMode.SuggestAppend; combo.AutoCompleteSource = AutoCompleteSource.ListItems; fpSpread1.Sheets0.Cells0, 0.CellType = combo; 产品网站: 12 of 80 效果截图 : / /通过继承 ComboCellType 实现 / public class ImageCombo : FarPoint.Win.Spread.CellType.ComboBoxCellType public override void PaintCell(Graphics g, Rectangle r, FarPoint.Win.Spread.Appearance appearance, object value, bool isSelected, bool isLocked, float zoomFactor) if (value != null) int ind =0; for (int i = 0; i base.Items.Length; i+) if (base.Itemsi = value.ToString() ind = i; break; Image img = base.ImageList.Imagesind; g.DrawImage(img, newRectangle(newPoint(r.X, r.Y), newSize(20, 20); g.DrawString(value.ToString(), appearance.Font, newSolidBrush(Color.Black), newPointF(r.X + 20, r.Y-10 + 10); ControlPaint.DrawComboButton(g, newRectangle(r.Right - 17, r.Y, 17, r.Height), ButtonState.Normal); else base.PaintCell(g, r, appearance, value, isSelected, isLocked, zoomFactor); 产品网站: 13 of 80 示例下载: 点击下载 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 CheckBoxCellType 的点击事件 问题描述 : 如何 获取 CheckBoxCellType 的点击事件。 问题 解答: CheckBoxCellType 提供 了 EditorValueChanged 事件 用于捕获 按钮 点击事件。 关键代码 : 示例下载: 点击下载 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 DoubleCellType 设置 为 会计专用 格式 问题描述 :如何设置 DoubleCellType 的 分隔符、小数位以及数值范围 。 问题 解答: DoubleCellType 提供 了 DecimalSeparator、 DecimalPlaces 和 MaximumValue 等 属性分别用于设置分隔符 、 小数位以及数值范围等。 关键代码 : / /添加 CheckBoxCellType / private void AddCellType() FarPoint.Win.Spread.CellType.CheckBoxCellType ckbxcell = new FarPoint.Win.Spread.CellType.CheckBoxCellType(); ckbxcell.TextAlign = FarPoint.Win.ButtonTextAlign.TextRightPictLeft; ckbxcell.Caption = Item Selected?; /添加点击事件 ckbxcell.EditorValueChanged += newEventHandler(ckbxcell_EditorValueChanged); fpSpread1.Sheets0.Cells2, 2.CellType = ckbxcell; void ckbxcell_EditorValueChanged(object sender, EventArgs e) MessageBox.Show(CheckBox 点击 ); 产品网站: 14 of 80 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 ImageCellType 如何 让图片 自适应 单元格大 小 问题描述 : 使用 ImageCellType 在 单元格中插入图片时,使图片 自适应 单元格大小。 问题 解答: ImageCellType 提供 Style 属性 用于设置图片在单元格中的显示方式。 关键代码 : 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 向用户开放向单元格 添加 图片 的功能 问题描述 : 双击 单元格 ,然后弹出 图片 选择 对话框 ,然后把图片插入到该单元格 。 问题 解答: 可以 通过 CellDoubleClick 事件 来捕获双击 Spread 事件,然后通过 ImageCellType 插入选择图片。 关键代码 : / /设置 NumberCellType 单元格类型 / private void AddCellType() FarPoint.Win.Spread.CellType.NumberCellType nmbrcell = new FarPoint.Win.Spread.CellType.NumberCellType(); /设置分隔符 nmbrcell.DecimalSeparator = ,; /设置小数位 nmbrcell.DecimalPlaces = 5; /设置整数位为 0时是否显示 nmbrcell.LeadingZero = FarPoint.Win.Spread.CellType.LeadingZero.UseRegional; /设置最大值 nmbrcell.MaximumValue = 500.000; /设置最小值 nmbrcell.MinimumValue = -10.000; fpSpread1.ActiveSheet.Cells1, 1.CellType = nmbrcell; FarPoint.Win.Spread.CellType.ImageCellType icelltype = new FarPoint.Win.Spread.CellType.ImageCellType(); /设置图片自适应单元格大小 icelltype.Style = FarPoint.Win.RenderStyle.Stretch; 产品网站: 15 of 80 示例下载: 点击下载 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相 关章节。 DateTimeCellType 日期格式的问题 问题描述 : 单元格 中的日期格式显示为 2011-3-14 如何 更改为 2011 年 03 月 14 日 的格 式。 问题 解答: DateCellType 下 UserDefinedFormat 属性 用 于获取 或设置日期显示格式。 关键代码 : / / 添加 ImageCellType / private void AddCellType() FarPoint.Win.Spread.CellType.ImageCellType imgct = new FarPoint.Win.Spread.CellType.ImageCellType(); System.Drawing.Image image = System.Drawing.Image.FromFile(Tulips.jpg); imgct.Style = FarPoint.Win.RenderStyle.Stretch; imgct.TransparencyColor = Color.Black; imgct.TransparencyTolerance = 20; fpSpread1.Sheets0.Columns1, 2.Width = 100; fpSpread1.Sheets0.Rows1, 1.Height = 50; fpSpread1.Sheets0.Cells1, 1.CellType = imgct; fpSpread1.Sheets0.Cells1, 1.Value = image; this.fpSpread1.CellDoubleClick += new FarPoint.Win.Spread.CellClickEventHandler(fpSpread1_CellDoubleClick); /双击弹出选择对话框 private void fpSpread1_CellDoubleClick(object sender, FarPoint.Win.Spread.CellClickEventArgs e) if (fpSpread1.ActiveSheet.ActiveCell.CellType is FarPoint.Win.Spread.CellType.ImageCellType) OpenFileDialog dlgOpen = new OpenFileDialog(); dlgOpen.Filter = *.jpg|*.jpg; if (dlgOpen.ShowDialog() = System.Windows.Forms.DialogResult.OK) fpSpread1.ActiveSheet.ActiveCell.Value = System.Drawing.Image.FromFile(dlgOpen.FileName); 产品网站: 16 of 80 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 限制 单元格 输入 最大输入长 度 问题描述 :限制单元格文本长度在 40 个 字符。 问题 解答: TextCellType 提供 了 MaxLength 属性 用 于 获取或设置输入文本最大长度。 关键代码 : 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 如何 实现 隐藏 输入文本 , 类似于密码输入框 问题描述 :如题 问题解答 : TextCellType 提供 了 PasswordChar 属性 用于 获取 或设置替代字符。 关键代码 : / /设置 DateTimeCellType 单元格类型 / private void AddCellType() FarPoint.Win.Spread.CellType.DateTimeCellType dt = new FarPoint.Win.Spread.CellType.DateTimeCellType(); dt.DateTimeFormat = FarPoint.Win.Spread.CellType.DateTimeFormat.UserDefined; dt.UserDefinedFormat = yyyy 年 MM月 dd日 ; fpSpread1.ActiveSheet.Cells0, 0.CellType = dt; fpSpread1.ActiveSheet.Cells0, 0.Value = System.DateTime.Now; fpSpread1.ActiveSheet.Columns0.Width = 130; FarPoint.Win.Spread.CellType.TextCellType txt = new FarPoint.Win.Spread.CellType.TextCellType(); txt.CharacterCasing = CharacterCasing.Upper; txt.CharacterSet = FarPoint.Win.Spread.CellType.CharacterSet.Ascii; txt.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show; txt.MaxLength = 40; txt.Multiline = true; txt.ScrollBars = ScrollBars.Vertical; txt.Static = true; fpSpread1.Sheets0.Cells0, 0.CellType = txt; fpSpread1.Sheets0.Cells0, 0.Text = This is a text cell. It can provide a wide range of + functionality for handlinga large amount of data that a user might want to include + in a single cell.; 产品网站: 17 of 80 效果 截图: 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 HyperLinkCellType 设置 点击 不打开网页 问题描述 : 单元格 设置为 HyperLinkCellType时,点击 就会 打开网页,如何禁止网页打开。 问题 解答: HyperLinkCellType 提供了 Locked 属性 用于 获取或 设置 是否 打开网页。 关键代码 : 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 MaskCellType 在 单元格中显示固定 占位符 问题描述 : 单元格 进入编辑状态后 ,如何 显示固定的 占位符 。 问题解答: MaskCellType 提供 了 Mask 属性用于获取或设置编辑固定格式。 关键代码 : FarPoint.Win.Spread.CellType.TextCellType txt = new FarPoint.Win.Spread.CellType.TextCellType(); txt.PasswordChar = Convert.ToChar(*); fpSpread1.Sheets0.Cells0, 0.CellType = txt; fpSpread1.Sheets0.Cells0, 0.Text = This is a text cell.; /锁定单元格即可禁止打开网页 this.fpSpread1.ActiveSheet.Columns1.Locked = true; this.fpSpread1.ActiveSheet.Columns1.VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center; this.fpSpread1.ActiveSheet.Columns1.Width = 45; 产品网站: 18 of 80 效果 截图: 示例下载: 点击下载 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 MultiColumnComboBoxCellType 实现 下拉表单 问题描述 :能否在点击单元格时, 根据 当前单元格信息 , 弹出其相对应的 数据库 子表单。 问题解答 : MultiColumnComboBoxCellType 单元格 类型 可以 绑定 DataTable,并且以下拉框方式 显示 。 关键代码 : / /添加 MaskCellType 单元格类型 / privatevoid AddCellType() FarPoint.Win.Spread.CellType.MaskCellType mc = new FarPoint.Win.Spread.CellType.MaskCellType(); mc.Mask = 电话号码: XXX-XXXX-XXXX; mc.MaskChar = Convert.ToChar(X); fpSpread1.ActiveSheet.Cells0, 1.CellType = mc; fpSpread1.ActiveSheet.Columns1.Width = 150; 产品网站: 19 of 80 效果 截图: 示例下载: 点击下载 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 怎么使单元格文本竖直显示 问题描述: 单元格 有多个字 符 ,不 使用 换行符, 如何 自动 竖直 显示。 问题 解答: TextCellType 提供 了 TextOrientation 属性 用户设置文本显示 方向 。 关键代码 : 效果 截图: /设置 MultiColumnComboBoxCellType FarPoint.Win.Spread.CellType.MultiColumnComboBoxCellType mcb = new FarPoint.Win.Spread.CellType.MultiColumnComboBoxCellType(); mcb.DataSourceList = dt; mcb.DataColumn = 2; mcb.ColumnEdit = 2; mcb.ButtonAlign = FarPoint.Win.ButtonAlign.Left; mcb.ListAlignment = FarPoint.Win.ListAlignment.Right; mcb.ListWidth = 500; mcb.ListOffset = 5; mcb.MaxDrop = 5; fpSpread1.ActiveSheet.Cells0, 0.CellType = mcb; FarPoint.Win.Spread.CellType.TextCellType tct = new FarPoint.Win.Spread.CellType.TextCellType(); tct.TextOrientation = FarPoint.Win.TextOrientation.TextVertical; this.fpSpread1.ActiveSheet.Cells0, 0.CellType = tct; this.fpSpread1.ActiveSheet.Cells0, 0.Text = 设置文本竖直显示 ; 产品网站: 20 of 80 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 RichTextCellType 实现 上 下 标 问题描述 : Spread 实现上下标格式。例如: X3 问题解答 : RichTextCellType 可以通过 RichTextBox 的 Rtf 属性 赋值 ,所以 任何 可以在 RichTextBox 实现 的样式都可以在单元格中显示。 关键代码 : 效果截图: RichTextBox rtbsup = newRichTextBox(); rtbsup.SelectedText = 天然气体积 =100m3; rtbsup.SelectionStart = 10; rtbsup.SelectionLength = 1; rtbsup.SelectionCharOffset = 5; /位移的像素,正数为上移,负数为下移 FarPoint.Win.Spread.CellType.RichTextCellType rtct = new FarPoint.Win.Spread.CellType.RichTextCellType(); this.fpSpread1.ActiveSheet.Cells0, 0.CellType = rtct; this.fpSpread1.ActiveSheet.Cells0, 0.Value = rtbsup.Rtf; 产品网站: 21 of 80 示例下载: 点击下载 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 自定义 单元格类型实现 PopupCellType 问题描述 : 如题 。 问题 解答: 可以 通过继承 Spread GeneralCellType , 重载 GetEditorControl 方法 来 指定 编辑器。 关键代码 : 效果 截图: public class PopupCellType : FarPoint.Win.Spread.CellType.GeneralCellType TypeControl control = newTypeControl(); Public override Control GetEditorControl(Control parent, FarPoint.Win.Spread.Appearance appearance, float zoomFactor) return control; 产品网站: 22 of 80 示例下载: 点击下载 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 7. 单元格 交互 本章节 中将列举 了 Spread 用户在实际项目中遇到的 典型单元格 交互问题 。 获取选择范围 问题分析 : 当 Spread 选择有个 多个不连续选择范围时,如何获取这些选择范围。 问题解答 : Spread提供 GetSelections 方法 用于 获取 当前的选择范围。 关键 代码 : 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 如何使单元格 Node 的提示,在单元格的右下 角 问题描述:设置 Note 的显示位置。 /获取选择单元格范围数组 CellRange crs = this.fpSpread1.ActiveSheet.GetSelections(); /输出选择范围单元格信息 foreach (CellRange range in crs) int rowStart = range.Row; int colStart = range.Column; int rowCount = range.RowCount; int colCount = range.ColumnCount; Debug.WriteLine(CellRange 起始单元格 :Cell + rowStart.ToString() + , + colStart.ToString() + + ,结束单元格 :Cell + (rowStart + rowCount - 1).ToString() + , + (colStart + colCount - 1).ToString() + ); 产品网站: 23 of 80 问题 解答:可以通过 Cell 类 下 NoteIndicatorPosition 属性 获取和设置 Note 显示 位置。 关键代码: 效果 截图: 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 如何调整 note 大 小 问题描述: note 里的字太多,怎么 调整 note 宽度, 显示完整的提示 信息 。 问题 解答:可以通过 TextTipFetch 事件获取当前 Note 显示 事件, 通过 TipWidth 属性 设置其宽度。 关键代码: fpSpread1.Sheets0.AllowNoteEdit = true; fpSpread1.Sheets0.Cells1, 1.Note = test; fpSpread1.Sheets0.Cells1, 1.NoteIndicatorColor = Color.Green; fpSpread1.Sheets0.Cells1, 1.NoteStyle = FarPoint.Win.Spread.NoteStyle.StickyNote; fpSpread1.Sheets0.Cells1, 1.NoteIndicatorPosition = FarPoint.Win.Spread.NoteIndicatorPosition.BottomRight; fpSpread1.Sheets0.RowCount = 2; fpSpread1.Sheets0.ColumnCount = 2; 产品网站: 24 of 80 效果截图: 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 切换 单元格焦点 问题描述 :如何 指定 Spread 焦点 到指定单元格。 问题 解答: Sheet 提供了 SetActiveCell 方法用于 切换 活跃 单元格 位置。 关键代码 : 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 输入法 全角半角切换 问题 描述:如题 private void Form1_Load(object sender, EventArgs e) fpSpread1.ActiveSheet.Cells0, 0.Note = 测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试 ; this.fpSpread1.TextTipFetch+=new FarPoint.Win.Spread.TextTipFetchEventHandler(fpSpread1_TextTipFetch); private void fpSpread1_TextTipFetch(object sender, FarPoint.Win.Spread.TextTipFetchEventArgs e) if (e.FetchCellNote) e.TipWidth = 500; /设置焦点到固定单元格 this.fpSpread1.ActiveSheet.SetActiveCell(3, 3); 产品网站: 25 of 80 问题解答 : Spread和 Cell 级别 都提供了 ImeMode属性用于控制 输入 法的全角及半角状态 。 Cell ImeMode优先级 高于 Spread。 关键 代码: 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 单元格合并后的宽度怎么取 问题描述:如题 问题 解答: Spread 提供了 GetCellRectangle 方法 用于获取 单元格 宽度。 关键 代码: 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 如果第一列不同,则第二列不合并 问题描述 : 如果前一列单元格内容不同,第二列即使内容相同也不合并,如图 问题 解答: 可以 通过指定 SetColumnMerge 方法中枚举 类型为 MergePolicy.Restricted 来 实现此功能。 关键 代码: 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 设置单元格文本对齐方式 问题描述:如题 问题解答 :单元格 提供了 HorizontalAlignment 和 VerticalAlignment 属性,分别 用于获取或设置单元格/设置半角输入 this.fpSpread1.ImeMode = System.Windows.Forms.ImeMode.Hangul; /设置全角输入 this.fpSpread1.ImeMode = System.Windows.Forms.ImeMode.HangulFull; fpSpread1.ActiveSheet.Cells1, 1.Text = 测试获取合并单元格宽度 ; fpSpread1.ActiveSheet.AddSpanCell(1, 1, 2, 3); /获取目标单元格所在的矩形 int spanCellWidth = fpSpread1.GetCellRectangle(0, 0, 1, 1).Width; this.fpSpread1.ActiveSheet.SetColumnMerge(-1, MergePolicy.Restricted); 产品网站: 26 of 80 水平和垂直方法对其方式。 关键代码 : 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 设置单元格文本溢出 问题描述:单元格文本内容过 多 长度 超过单元格宽度 时, 如何设置其溢出显示。 问题解答 : Spread 提供了 AllowCellOverflow 和 AllowEditOverflow 分别 用于获取和设置 显示 和编辑状态下 文本 是否溢出。 关键 代码: 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 Spread Cell 文字自适应 单元格 宽度 问题描述 :如果 Spread Cell 文字长度超过 Cell 的宽度,则自动缩小,否则正常显示,类似于 EXCEL 的shrink to fit (文字长度自 适应 )。 问题 解答: TextCellType 提供 了 ShrinkToFit 属性 来获取或设置文本是否自适应单元格长度。 关键代码 : 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 如何 禁止拖拽选择单元格范围 问题描述 : 在 表单中 拖拽 鼠标时,如何禁止其选择范围,每次只能选择一个单元格。 问题 解答:可以通过 设置 SelectionPolicy 来 设置选择单位 , 实现此功能。 关键 代码: fpSpread1.Sheets0.Cells0,0.HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Right; fpSpread1.Sheets0.Cells0,0.VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Bottom; fpSpread1.Sheets0.Cells1,1,2,2.HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center; fpSpread1.Sheets0.Cells1,1,2,2.VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center; /允许单元格文本在编辑状态下溢出 fpSpread1.AllowCellOverflow = true; /允许单元格文本在编辑状态下溢出 fpSpread1.AllowEditOverflow = true; fpSpread1.Sheets0.Cells0, 0.Text = 溢出文本测试溢出文本测试溢出文本测试溢出文本测试 ; FarPoint.Win.Spread.CellType.TextCellType currcell = new FarPoint.Win.Spread.CellType.TextCellType(); currcell.ShrinkToFit = true; fpSpread1.Sheets0.Cells0, 0.CellType = currcell; fpSpread1.Sheets0.Cells0, 0.Text = 测试测试测试测试测试 ; 产品网站: 27 of 80 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 拖拽 填充公式 问题描述 : 如何通过鼠标拖拽单元格添加 公式 。 问题解答:当 拖拽单元格存在公式时,只需要设置 AllowDragDrop 和 AllowDragFill 为 true 即可实现此功能。 关键 代码: 示例下载: 点击下载 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 8. 边框 及 网格线 设置 本章节 中将列举 了 Spread 用户在实际项目中遇到的 典型边框 设置问题 。 包括更改 默认 焦点 指示器 颜色 及更改渲染器背景色等。 如何 更改焦点 指示器 问题描述 :选择单元格时, 默认 单元格会出现黑色边框来突出单元格 选择 的状态 , 如何修改指示器样式 。 如图 所示 : this.fpSpread1.Sheets0.SelectionPolicy = FarPoint.Win.Spread.Model.SelectionPolicy.Single; privatevoid InitSpread() this.fpSpread1.ActiveSheet.Cells0, 2.Formula = SUM(A1:B1); this.fpSpread1.AllowDragDrop = true; this.fpSpread1.AllowDragFill = true; private void fpSpread1_DragFillBlock(object sender, FarPoint.Win.Spread.DragFillBlockEventArgs e) e.DataOnly = false; 产品网站: 28 of 80 问题 解答: 可以通过 实现 IFocusIndicatorRenderer 接口,手动 绘制焦点指示器 。 关键代码 : public class MyIndicator : FarPoint.Win.Spread.IFocusIndicatorRenderer public void Paint(System.Drawing.Graphics g, int x, int y, int width, int height, bool left, bool top, bool right, bool bottom) SolidBrush r = new SolidBrush(System.Drawing.Color.Red); SolidBrush b = new SolidBrush(System.Drawing.Color.Blue); SolidBrush gr = new SolidBrush(System.Drawing.Color.DarkGreen); g.FillRectangle(r, x, y, 1, height); g.FillRectangle(gr, x, y, width, 1); g.FillRectangle(r, x + width - 1, y, 1, height); g.FillRectangle(b, x, y + height - 1, width, 1); 产品网站: 29 of 80 效果截图 : 示例下载: 点击下载 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 如何 修改选择单元格 渲染器 的背景色 问题描述 :单元格被选择时,背景色会暂时改变, 如图蓝色 部分所示: 问题 解答: 可以通过 实现 ISelectionRenderer 接口,手动填充 选择背景色 。 产品网站: 30 of 80 关键代码 : 效果如图 : public class SelectionRenderer : FarPoint.Win.Spread.ISelectionRenderer public void PaintSelection(Graphics g, int x, int y, int width, int height) SolidBrush selectionBrush = new SolidBrush(Color.FromArgb(100, Color.Green); g.FillRectangle(selectionBrush, x, y, width, height); selectionBrush.Dispose(); 产品网站: 31 of 80 示例下载: 点击下载 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 如何隐藏 默认的横向网格线 问题描述 :如题 问题 解答: 可以 通过 SheetView 下 的 HorizontalGridLine和 VerticalGridLine来获取 或设置网格线样式 。 关键 代码: 效果 截图: this.fpSpread1.Sheets0.HorizontalGridLine = new GridLine(GridLineType.None); 产品网站: 32 of 80 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 如何设置列边框颜色 问题 描述 : 如何 以列为单位设置边框样式。 问题解答: Spread 提供了 LineBorder 和 BevelBorder 类 用于设置 边框 。 关键代码: 效果截图: FarPoint.Win.LineBorder lineborder = new FarPoint.Win.LineBorder(Color.Green, 2, true, true, true, true); fpSpread1.Sheets0.Columns0.Border = lineborder; fpSpread1.BorderCollapse = FarPoint.Win.Spread.BorderCollapse.Collapse; 产品网站: 33 of 80 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 9. 行列 交互 本章节 中将列举 了 Spread 用户在实际项目中遇到的 典型行列 交互问题 。 包括 冻结行列 和 移动行列等。 在冻结的行或列中,如何实现在右键单击处的单元格被选中 问题描述 : 如题 问题 解答: Spread 提供 MouseDown 事件 用于获取鼠标点击事件,在事件中可以通过HitTestInformation 类 获取当前操作的单元格。 关键代码 : 示例下载: 点击下载 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 让所有列的宽度自动适应 文本 宽度怎么设 置 问题描述 :如题 问题 解答: 可以 通过 SheetView 下 GetPreferredColumnWidth 方法 获取文本长度,进而设置给当前列。 关键 代码: private void Form1_Load(object sender, EventArgs e) this.fpSpread1.Sheets0.FrozenRowCount = 1; this.fpSpread1.MouseDown += newMouseEventHandler(fpSpread1_MouseDown); private void fpSpread1_MouseDown(object sender, MouseEventArgs e) /获取当前鼠标点击单元格信息 HitTestInformationhtinfo = this.fpSpread1.HitTest(e.X, e.Y); int curRow = htinfo.ViewportInfo.Row; /判断是否点击在冻结行 if (e.Button = System.Windows.Forms.MouseButtons.Right & curRow = 0) FarPoint.Win.Spread.HitTestInformation hitTest = this.fpSpread1.HitTest(e.X, e.Y); int row = hitTest.ViewportInfo.Row; int col = hitTest.ViewportInfo.Column; this.fpSpread1.Sheets0.SetActiveCell(row, col); 产品网站: 34 of 80 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 如何 设置交替行颜色 问题描述 :如题 问题解答 : AlternatingRows 用于 定制 交替行 样式, Count 属性 用于 获取 或设置交替行个数 。 关键 代码: 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 如何 设置列可移动 问题描述 :如题 问题 解答: 移动 单列和多列分别通过 AllowColumnMove 和 AllowColumnMoveMultiple 属性 控制。 关键 代码: 允许 移动单列 允许 移动多列 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 设置 ColumnFooter 合计 问题描述 : 在 CoumnFooter 中加入 合计 公式 ,对 表单 的某数值列进行合计? 问题 解答: ColumnFooter.SetAggregationType 方法 用于设置 公式 类型 及所在 位置。 关键 代码: for (int i = 0; i this.fpSpread1.ActiveSheet.ColumnCount; i+) /获取该列文本宽度 float fitColumnWidth = this.fpSpread1.ActiveSheet.GetPreferredColumnWidth(i); this.fpSpread1.ActiveSheet.Columnsi.Width = fitColumnWidth; fpSpread1.Sheets0.AlternatingRows.Count = 2; fpSpread1.Sheets0.AlternatingRows0.BackColor = Color.Yellow; fpSpread1.Sheets0.AlternatingRows0.ForeColor = Color.LightCyan; fpSpread1.Sheets0.AlternatingRows1.BackColor = Color.LightSeaGreen; fpSpread1.Sheets0.AlternatingRows1.ForeColor = Color.LightYellow; this.fpSpread1.AllowColumnMove = true; this.fpSpread1.AllowColumnMoveMultiple = true; 产品网站: 35 of 80 效果 截图: 示例下载: 点击下载 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 实现 多行选择 问题描述 : 如何 实现 以 行为单位进行选择,并且可以选择多行。 问题 解答: SelectionUnit 用于 获取或设置选择单位, SelectionPolicy 用于 获取或设置选择 策略 。 关键 代码: 效果截图: /设置列脚的可见性 fpSpread1.Sheets0.ColumnFooter.Visible = true; /设计合计公式 fpSpread1.Sheets0.ColumnFooter.SetAggregationType(0, 3, FarPoint.Win.Spread.Model.AggregationType.Sum); /设计合计公式格式 fpSpread1.Sheets0.ColumnFooter.SetAggregationFormat(0, 3, 合计 :0); fpSpread1.Sheets0.ColumnFooter.Cells0, 0.Value = Sum; this.fpSpread1.ActiveSheet.SelectionUnit = FarPoint.Win.Spread.Model.SelectionUnit.Row; this.fpSpread1.ActiveSheet.SelectionPolicy = FarPoint.Win.Spread.Model.SelectionPolicy.MultiRange; 产品网站: 36 of 80 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 10. 表单 交互 本章节 中将列举 了 Spread 用户在实际项目中遇到的 典型表单 交互问题 。 Sheet 添加 上下文菜单 问题描述 : Spread 表单 如何添加上下文菜单。 问题 解答: Spread 提供 了 ContextMenu 接口可以用户获取或设置上下文菜单 。 关键代码: 效果截图: ContextMenu cm = newContextMenu(); cm.MenuItems.Add(剪切 ); cm.MenuItems.Add(复制 ); cm.MenuItems.Add(粘贴 ); cm.MenuItems.Add(删除 ); this.fpSpread1.ContextMenu = cm; 产品网站: 37 of 80 示例下载: 点击下载 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 如何 定制 表角 SheetCorner 问题描述 :如何操作 表单表角 的行列数、样式以及文本等信息。 问题 解答: 可以 通过 SheetView 下 属性 SheetCorner 来 操作表角。 关键 代码: fpSpread1.ActiveSheet.SheetCorner.DefaultStyle.Renderer = new FarPoint.Win.Spread.CellType.CornerRenderer(); fpSpread1.ActiveSheet.AllowTableCorner = true; fpSpread1.ActiveSheet.SheetCorner.RowCount = 6; fpSpread1.ActiveSheet.SheetCorner.ColumnCount = 6; fpSpread1.ActiveSheet.SheetCorner.AlternatingRows0.BackColor = Color.Violet; fpSpread1.ActiveSheet.SheetCorner.Cells0, 0.Text = 测试 ; fpSpread1.ActiveSheet.SheetCorner.Columns0.Border = new FarPoint.Win.LineBorder(Color.Green); fpSpread1.ActiveSheet.SheetCorner.Rows0.Border = new FarPoint.Win.LineBorder(Color.Green); fpSpread1.ActiveSheet.SheetCorner.HorizontalGridLine = new FarPoint.Win.Spread.GridLine(FarPoint.Win.Spread.GridLineType.None); fpSpread1.ActiveSheet.SheetCorner.VerticalGridLine = new FarPoint.Win.Spread.GridLine(FarPoint.Win.Spread.GridLineType.None); fpSpread1.ActiveSheet.SheetCorner.DefaultStyle.VisualStyles = FarPoint.Win.VisualStyles.Off; 产品网站: 38 of 80 效果 截图 : 示例 下载 : 点击 下载 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 如何 操作 列脚 ColumnFooter 问题描述 :表 单中 有列 脚 功能, 如何操作列脚 的行列数、样式以及文本等信息。 问题解答 : 可以 通过 SheetView 下 属性 ColumnFooter 来 操作 列脚 。 关键 代码: 效果截图 : fpSpread1.Sheets0.ColumnFooter.Visible = true; fpSpread1.Sheets0.ColumnFooter.RowCount = 2; fpSpread1.Sheets0.ColumnFooter.DefaultStyle.ForeColor = Color.Purple; fpSpread1.Sheets0.ColumnFooter.Columns12.HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Left; fpSpread1.Sheets0.ColumnFooter.Cells0, 12.RowSpan = 2; fpSpread1.Sheets0.ColumnFooter.Cells0, 0.Value = test; 产品网站: 39 of 80 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 如何 使 单元格被 选中 即 进入 编辑 模式 问题描述 : 如题 问题 解答: Spread 提供 EditModePermanent 用户 实现此功能。 关键 代码 : 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 11. 排序 本章节 中将列举 了 Spread 用户在实际项目中遇到的 典型排序 问题 。 您可以在表单中根据行或 列 排列数据。典型的示例是:在表单中,所有的行根据某一特定列 排序。但是 Spread允许排序以各种方法执行。 排序 功能包括 自动 排序 、 对 对若干行,若干列,或者一个区域进行排序。 针对单元格 范围内排序 问题描述: 如题 问题 解答: SortRange 方法 用于指定排序范围。 关键 代码: 示例下载: 点击下载 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 /设置活跃单元格进入编辑状态 fpSpread1.EditModePermanent = true; /设置单元格进入编辑状态时全选文本 fpSpread1.EditModeReplace = true; fpSpread1.ActiveSheet.SortRange(0, 0, 4, 2, true, sort); 产品网站: 40 of 80 如何 实现冻结行不参加排序 问题描述 :如题 问题解答 : Spread 排序时会触发 AutoSortingColumn 事件 ,可以在该事件中指定排序范围。 关键代码 : 效果截图 : 示例下载: 点击下载 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 private void fpSpread1_AutoSortingColumn(object sender, FarPoint.Win.Spread.AutoSortingColumnEventArgs e) /取消排序 e.Cancel = true; /重新设置排序范围 this.fpSpread1.Sheets0.SortRows(0, 5, new FarPoint.Win.Spread.SortInfo new FarPoint.Win.Spread.SortInfo(e.Column, false) ); 产品网站: 41 of 80 12. 过滤 本章节 中将列举 了 Spread 用户在实际项目中遇到的 典型过滤 问题 。 您可以通过 实现过滤功能来提高 用户体验。 基于行数据过滤 ,您可以允许用户分列进行过滤 ,仅显示 符合 下拉列表中条件的行 数据,或者根据筛选结果更改行的外观。 您 可以使用使用默认的过滤方式,或者您可以从实际用户 需求 出发,自定义过滤 器 。 如何 获取过滤行 问题描述 :过滤后如何获取 符合 过滤条件的行。 问题 解答: 过滤后 ,可以通过 GetIntersectedFilteredInRows 方法 获取如何过滤条件的索引数组。 关键 代码: 示例下载: 点击下载 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 如何 使冻结行列不参与过滤 问 题描述 :如题 问题 解答:可以通过 SheetView 下 UnfilteredRows 属性 设置不参与过滤行的 数组 。 关键 代码: 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 自定义过滤 选项 问题描述:如何自定义过滤项 问题 解答: Spread 提供了 CustomFilter 类 来自定义过滤条件。 关键代码: int array = this.fpSpread1_Sheet1.RowFilter.GetIntersectedFilteredInRows(); private void SetUnfilterRow() int unfilterRows = newint3 0, 8, 9 ; this.fpSpread1.Sheets0.RowFilter.UnfilteredRows = unfilterRows; 产品网站: 42 of 80 效果 截图: 示例下载: 点击下载 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 13. 数据 搜索 本章节 中将列举 了 Spread 用户在实际项目中遇到的 典型搜索 问题 。 您可以使用代码执行检索操作,或者为您的用户提供一个具有各种选项的检索对话框。 Spread 如何实现搜索 功能 问题描述 :如题 问题 解答: Spread本身 即内置了搜索功能, 可以 通过 SearchWithDialogAdvanced 调用 高级搜索 对话框 。 关键 代码: 效果 截图: FarPoint.Win.Spread.FilterColumnDefinition fcd1 = new FarPoint.Win.Spread.FilterColumnDefinition(0, FarPoint.Win.Spread.FilterListBehavior.Custom); CustomFilter _cFilter = newCustomFilter(fpSpread1.ActiveSheet, 自定义条件 1); fcd1.Filters.Add(_cFilter); CustomFilter _cFilter1 = newCustomFilter(fpSpread1.ActiveSheet, 自定义条件 2); fcd1.Filters.Add(_cFilter1); sf.AddColumn(fcd1); fpSpread1.ActiveSheet.RowFilter = sf; this.fpSpread1.ActiveSheet.Cells10, 10.Text = test; /目标搜索文体为 test fpSpread1.SearchWithDialogAdvanced(test); 产品网站: 43 of 80 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节。 14. 数据绑定 本章节 中将列举 了 Spread 用户在实际项目中遇到的 典型数据 绑定问题 。 您可以把 Spread 控件绑定到任意的数据集中,如数据库中的数据,或者任何其他 .NET 框架允许使用的数据集类型,如实现了 IList 接口的对象。 指定绑定列 问题描述 :默认 情况下, Spread 绑定 数据时会按照默认字段顺序 绑定 到表单, 如何 调整字段的绑定 顺序 。 问题解答 : Spread 提供 了 AutoGenerateColumns 用于 设置是否 按照 默认字段顺序绑定 表单 。 关键 代码: 效果 截图: /关闭自动生成列属性 fpSpread1.Sheets0.AutoGenerateColumns = false; /绑定数据源 fpSpread1.DataSource = dt; /指定特定列字段 fpSpread1.Sheets0.Columns0.DataField = 名称 ; fpSpread1.Sheets0.Columns2.DataField = 售价 ; fpSpread1.Sheets0.Columns4.DataField = 编码 ; 产品网站: 44 of 80 示例下载: 点击下载 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 区域 数据 绑定 问题描述: 不希望绑定整个表单,只 针对表单中某一区域绑定。 问题解答: Spread 提供 SpreadDataBindingAdapter 方法用于绑定数据到特定单元格区域。 关键代码 : 效果 截图: FarPoint.Win.Spread.Data.SpreadDataBindingAdapter data = new FarPoint.Win.Spread.Data.SpreadDataBindingAdapter(); data.DataSource = dt; data.Spread = fpSpread1; data.SheetName = Sheet1; data.MapperInfo = new FarPoint.Win.Spread.Data.MapperInfo(3, 3, 3, 3); data.FillSpreadDataByDataSource( 产品网站: 45 of 80 示例下载 : 点击 下载 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 如何 绑定 List到 Spread 问题描述 :如题 问题解答: Spread 支持与一个数据集的绑定,如一个数据库中的数据,或任何 .NET 框架允许的数据,如IList 对象进行绑定。 关键 代码: 产品网站: 46 of 80 更多信息 请参考 Spread for WinForms V7.0 API 中文文档 相关章节 15. 数据可视化 本章节 中将列举 了 Spread 用户在实际项目中遇到的 典型的 数据可视化问题 。 Spread 支持丰富的数据可视化形式,包括 图表 、 波形图和条件格式化等 ,这些 功能使数据显示更加直观 ,增强 数据的可读性,大大提高用户 获取 数据 以及 理解数据 的体验 。 图表 直接 使用表单 数据作为数据源 创建 图表 问题描述:使用表单中的单元格数据作为数据源,直接生成图表。 问题解答: Sheetview 下提供了 AddChart 方法用于使用指定范围单元格作为数据源添加图表。 关键代码: private void Form1_Load(object sender, EventArgs e) List list = new List(); list.Add(new MyClass() P1 = A1, P2 = B1, P3 = C1 ); list.Add(new MyClass() P1 = A1, P2 = B1, P3 = C1 ); list.Add(new MyClass() P1 = A1, P2 = B1, P3 = C1 ); list.Add(new MyClass() P1 = A1, P2 = B1, P3 = C1 ); list.Add(new MyClass() P1 = A1, P2 = B1, P3 = C1 ); list.Add(new MyClass() P1 = A1, P2 = B1, P3 = C1 ); fpSpread1.ActiveSheet.DataSource = list; private class MyClass public string P1 get; set; public string P2 get; set; public string P3 get; set; 产品网站: 47 of 80 效果 截 图 : privatevoid Ad

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论