找回密码
 立即注册

QQ登录

只需一步,快速开始

yuanhs

中级会员

6

主题

19

帖子

727

积分

中级会员

积分
727

活字格认证微信认证勋章

最新发帖
yuanhs
中级会员   /  发表于:2015-11-11 14:21  /   查看:6197  /  回复:9
Font font = this.fpSpread1.ActiveSheet.ActiveCell.Font;
                if (font == null)
                {
                    font = fpSpread1.Font;
                }
                bool none = font == null;
                toolStripButtonB.Checked = none ? false : font.Bold;
                toolStripButtonI.Checked = none ? false : font.Italic;
                toolStripButtonU.Checked = none ? false : font.Underline;

                string sName = none ? "" : font.FontFamily.Name;
                string sSize = none ? "" : font.Size.ToString();

                toolStripComboBoxFont.Text = sName;
                toolStripComboBoxFontSize.Text = sSize;

toolStripComboBoxFont是c#标准的toolStripComboBox,在fpSpread的 SelectionChanged事件中对toolStripComboBoxFont.Text赋值就报错, 如果将上面的最后2行注释掉就没有问题。这是什么原因?该怎么处理

9 个回复

倒序浏览
frank.zhang
社区贡献组   /  发表于:2015-11-11 17:38:00
沙发
您好,

我使用以下方式,没有能够重现问题,您看下,是否遗漏了哪些重要步骤。
  1.         private void fpSpread1_SelectionChanged(object sender, FarPoint.Win.Spread.SelectionChangedEventArgs e)
  2.         {
  3.             this.toolStripComboBox1.Text = "123";
  4.         }
复制代码


2015-11-11_173743.jpg (21.59 KB, 下载次数: 285)
回复 使用道具 举报
yuanhs
中级会员   /  发表于:2015-11-12 10:45:00
板凳
你好:
http://pan.baidu.com/s/1ntF4MX7  这是源代码及问题的详细描述,现在是点击某个单元格就出错,而且我发现字体大小修改后 重复的点击2个单元格 来回点击 字体又变回原来大小了。
回复 使用道具 举报
frank.zhang
社区贡献组   /  发表于:2015-11-12 14:59:00
地板
您好,

您的问题已经重现,这个问题导致了一个内存错误,我会将这个问题提交给产品组,以确认是否是一个BUG。
回复 使用道具 举报
yuanhs
中级会员   /  发表于:2015-11-13 10:26:00
5#
回复 4楼frank.zhang的帖子

有什么进展麻烦您通知我下
回复 使用道具 举报
frank.zhang
社区贡献组   /  发表于:2015-11-13 11:51:00
6#
好的,

由于开发团队在美国,受到时差的影响需要2到3个工作日,希望能够谅解。
回复 使用道具 举报
yuanhs
中级会员   /  发表于:2015-11-23 13:42:00
7#
回复 6楼frank.zhang的帖子

你好 请问现在什么进展了
回复 使用道具 举报
Alice
社区贡献组   /  发表于:2015-11-23 14:29:00
8#
回复 7楼yuanhs的帖子

很抱歉,我们暂未收到产品组的回复,如果有反馈会在第一时间通知您。
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
yuanhs
中级会员   /  发表于:2015-11-27 00:20:00
9#
回复 8楼Alice的帖子

你好,我再请问下 咱有使用wpf  调用 winform中fpSpread 控件的例子吗 ,我想使用wpf 来实现fpSpread设计器。
回复 使用道具 举报
frank.zhang
社区贡献组   /  发表于:2015-11-27 17:09:00
10#
您好,

经过调查,这个问题是在客户的项目通过代码处置的字体??发生。
private void ChangeFont(string fontName, float size, FontStyle style, bool toogled, bool isToogle)
        {
            try
            {
                SheetView sheet = this.fpSpread1.ActiveSheet;
                CellRange[] cellRanges = GetSpreadSelections();
                foreach (CellRange cellRange in cellRanges)
                {
                    for (int i = 0; i < cellRange.RowCount; i++)
                    {
                        for (int j = 0; j < cellRange.ColumnCount; j++)
                        {
                            Font cellFont = sheet.GetStyleInfo(i + cellRange.Row, j + cellRange.Column).Font ?? fpSpread1.Font;
                            bool hasCellFont = sheet.Cells[i + cellRange.Row, j + cellRange.Column].Font != null;
                            sheet.Cells[i + cellRange.Row, j + cellRange.Column].Font = new Font(string.IsNullOrEmpty(fontName) ? cellFont.Name : fontName
                                                                                            , size > 0 ? size : cellFont.Size
                                                                                            , isToogle ? toogled ? cellFont.Style | style : cellFont.Style &amp; ~style : style
                                                                                            , cellFont.Unit);
                            if (hasCellFont)
                                cellFont.Dispose(); //=> Dispose the font is using.
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("ChangeFont" + ex.Message);
            }
}

解决方案:注释以下代码
          //if (hasCellFont)
         //    cellFont.Dispose(); //=> Dispose the font is using.
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部