找回密码
 立即注册

QQ登录

只需一步,快速开始

瑚边

注册会员

9

主题

29

帖子

92

积分

注册会员

积分
92
瑚边
注册会员   /  发表于:2019-3-25 12:36  /   查看:5534  /  回复:11
环境:
SPREAD for Windows Forms 10.0J
Windows 10 Pro (version 1709)

现象:
画面上有两个Spread,两个Spread结构相同,只有1行4列,其中前3列Canfocus为FALSE,只有第四列可以编辑,ImeMode设定为Hiragana。
两个Spread都绑定了Enter事件,Enter事件中只有一句代码:
  1. this.fpSpread1_Sheet1.SetActiveCell(0, 3);
复制代码

FormLoad事件中,设定了this.fpSpread1.Select();
现在的问题是,画面表示后,fpSpread1的最后一列Ime一直能正常表示为あ,
但当鼠标点击第二个Spread时,焦点会进入第二个Spread,这时,由于Enter事件中设定了Cell,focus在可编辑列上,可Ime始终为A,不能正常表示为あ。

而将Enter事件中的设置ActiveCell的处理注释掉,Ime就能够正常表示了。


由于不设置ActiveCell会导致点到可编辑列以外的区域时,Spread的第一列会出现Focus框,所以加了Enter事件来避免这个问题。
可是导致了Ime无法正常使用。这是BUG么?


11 个回复

倒序浏览
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2019-3-26 11:10:40
沙发
其实您是为了解决不能focus的列被foucus的问题。
我这边测试了,从别的控件再点回spread,也无法选中列,可否给个Demo重写此问题。
回复 使用道具 举报
瑚边
注册会员   /  发表于:2019-3-26 15:35:46
板凳
我找到了一个办法解决IME的问题。。在Form_Load事件里把出问题的Spread的备考栏先设成ActiveCell。。然后再设置原本初期的Focus控件。。这样画面表示后IME也正常了。。不能Focus的列被Focus的问题也解决了。。连RowEnter事件都不用加了。。尽管问题解决了。。可我还是觉得这个现象比较像个BUG。。。

以下是Designer的代码:
  1. namespace WindowsFormsApp2
  2. {
  3.     partial class Form2
  4.     {
  5.         /// <summary>
  6.         /// Required designer variable.
  7.         /// </summary>
  8.         private System.ComponentModel.IContainer components = null;

  9.         /// <summary>
  10.         /// Clean up any resources being used.
  11.         /// </summary>
  12.         /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
  13.         protected override void Dispose(bool disposing)
  14.         {
  15.             if (disposing && (components != null))
  16.             {
  17.                 components.Dispose();
  18.             }
  19.             base.Dispose(disposing);
  20.         }

  21.         #region Windows Form Designer generated code

  22.         /// <summary>
  23.         /// Required method for Designer support - do not modify
  24.         /// the contents of this method with the code editor.
  25.         /// </summary>
  26.         private void InitializeComponent()
  27.         {
  28.             FarPoint.Win.Spread.CellType.TextCellType textCellType9 = new FarPoint.Win.Spread.CellType.TextCellType();
  29.             FarPoint.Win.Spread.CellType.TextCellType textCellType10 = new FarPoint.Win.Spread.CellType.TextCellType();
  30.             this.fpSpread1 = new FarPoint.Win.Spread.FpSpread();
  31.             this.fpSpread1_Sheet1 = new FarPoint.Win.Spread.SheetView();
  32.             this.fpSpread2 = new FarPoint.Win.Spread.FpSpread();
  33.             this.sheetView1 = new FarPoint.Win.Spread.SheetView();
  34.             ((System.ComponentModel.ISupportInitialize)(this.fpSpread1)).BeginInit();
  35.             ((System.ComponentModel.ISupportInitialize)(this.fpSpread1_Sheet1)).BeginInit();
  36.             ((System.ComponentModel.ISupportInitialize)(this.fpSpread2)).BeginInit();
  37.             ((System.ComponentModel.ISupportInitialize)(this.sheetView1)).BeginInit();
  38.             this.SuspendLayout();
  39.             //
  40.             // fpSpread1
  41.             //
  42.             this.fpSpread1.AccessibleDescription = "fpSpread1, Sheet1, Row 0, Column 0, ";
  43.             this.fpSpread1.Location = new System.Drawing.Point(28, 12);
  44.             this.fpSpread1.Name = "fpSpread1";
  45.             this.fpSpread1.Sheets.AddRange(new FarPoint.Win.Spread.SheetView[] {
  46.             this.fpSpread1_Sheet1});
  47.             this.fpSpread1.Size = new System.Drawing.Size(472, 61);
  48.             this.fpSpread1.TabIndex = 0;
  49.             this.fpSpread1.Enter += new System.EventHandler(this.fpSpread1_Enter);
  50.             //
  51.             // fpSpread1_Sheet1
  52.             //
  53.             this.fpSpread1_Sheet1.Reset();
  54.             this.fpSpread1_Sheet1.SheetName = "Sheet1";
  55.             // Formulas and custom names must be loaded with R1C1 reference style
  56.             this.fpSpread1_Sheet1.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.R1C1;
  57.             this.fpSpread1_Sheet1.ColumnCount = 4;
  58.             this.fpSpread1_Sheet1.RowCount = 1;
  59.             this.fpSpread1_Sheet1.Cells.Get(0, 0).CanFocus = false;
  60.             this.fpSpread1_Sheet1.Cells.Get(0, 1).CanFocus = false;
  61.             this.fpSpread1_Sheet1.Cells.Get(0, 2).CanFocus = false;
  62.             this.fpSpread1_Sheet1.Cells.Get(0, 3).CellType = textCellType9;
  63.             this.fpSpread1_Sheet1.Cells.Get(0, 3).ImeMode = System.Windows.Forms.ImeMode.Hiragana;
  64.             this.fpSpread1_Sheet1.ColumnFooterSheetCornerStyle.HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.General;
  65.             this.fpSpread1_Sheet1.ColumnFooterSheetCornerStyle.NoteIndicatorColor = System.Drawing.Color.Red;
  66.             this.fpSpread1_Sheet1.ColumnFooterSheetCornerStyle.Parent = "CornerDefaultEnhanced";
  67.             this.fpSpread1_Sheet1.ColumnFooterSheetCornerStyle.VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.General;
  68.             this.fpSpread1_Sheet1.Columns.Get(0).BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
  69.             this.fpSpread1_Sheet1.Columns.Get(1).BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
  70.             this.fpSpread1_Sheet1.Columns.Get(2).BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
  71.             this.fpSpread1_Sheet1.RowHeader.Columns.Default.Resizable = false;
  72.             this.fpSpread1_Sheet1.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.A1;
  73.             //
  74.             // fpSpread2
  75.             //
  76.             this.fpSpread2.AccessibleDescription = "fpSpread2, Sheet1, Row 0, Column 0, ";
  77.             this.fpSpread2.Location = new System.Drawing.Point(28, 111);
  78.             this.fpSpread2.Name = "fpSpread2";
  79.             this.fpSpread2.Sheets.AddRange(new FarPoint.Win.Spread.SheetView[] {
  80.             this.sheetView1});
  81.             this.fpSpread2.Size = new System.Drawing.Size(472, 61);
  82.             this.fpSpread2.TabIndex = 1;
  83.             this.fpSpread2.Enter += new System.EventHandler(this.fpSpread2_Enter);
  84.             //
  85.             // sheetView1
  86.             //
  87.             this.sheetView1.Reset();
  88.             this.sheetView1.SheetName = "Sheet1";
  89.             // Formulas and custom names must be loaded with R1C1 reference style
  90.             this.sheetView1.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.R1C1;
  91.             this.sheetView1.ColumnCount = 4;
  92.             this.sheetView1.RowCount = 1;
  93.             this.sheetView1.Cells.Get(0, 0).BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
  94.             this.sheetView1.Cells.Get(0, 0).CanFocus = false;
  95.             this.sheetView1.Cells.Get(0, 1).BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
  96.             this.sheetView1.Cells.Get(0, 1).CanFocus = false;
  97.             this.sheetView1.Cells.Get(0, 2).BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
  98.             this.sheetView1.Cells.Get(0, 2).CanFocus = false;
  99.             this.sheetView1.Cells.Get(0, 3).CellType = textCellType10;
  100.             this.sheetView1.Cells.Get(0, 3).ImeMode = System.Windows.Forms.ImeMode.Hiragana;
  101.             this.sheetView1.ColumnFooterSheetCornerStyle.HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.General;
  102.             this.sheetView1.ColumnFooterSheetCornerStyle.NoteIndicatorColor = System.Drawing.Color.Red;
  103.             this.sheetView1.ColumnFooterSheetCornerStyle.VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.General;
  104.             this.sheetView1.FilterBarHeaderStyle.HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.General;
  105.             this.sheetView1.FilterBarHeaderStyle.NoteIndicatorColor = System.Drawing.Color.Red;
  106.             this.sheetView1.FilterBarHeaderStyle.VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.General;
  107.             this.sheetView1.RowHeader.Columns.Default.Resizable = false;
  108.             this.sheetView1.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.A1;
  109.             //
  110.             // Form2
  111.             //
  112.             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  113.             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  114.             this.ClientSize = new System.Drawing.Size(800, 450);
  115.             this.Controls.Add(this.fpSpread2);
  116.             this.Controls.Add(this.fpSpread1);
  117.             this.Name = "Form2";
  118.             this.Text = "Form2";
  119.             this.Load += new System.EventHandler(this.Form2_Load);
  120.             ((System.ComponentModel.ISupportInitialize)(this.fpSpread1)).EndInit();
  121.             ((System.ComponentModel.ISupportInitialize)(this.fpSpread1_Sheet1)).EndInit();
  122.             ((System.ComponentModel.ISupportInitialize)(this.fpSpread2)).EndInit();
  123.             ((System.ComponentModel.ISupportInitialize)(this.sheetView1)).EndInit();
  124.             this.ResumeLayout(false);

  125.         }

  126.         #endregion

  127.         private FarPoint.Win.Spread.FpSpread fpSpread1;
  128.         private FarPoint.Win.Spread.SheetView fpSpread1_Sheet1;
  129.         private FarPoint.Win.Spread.FpSpread fpSpread2;
  130.         private FarPoint.Win.Spread.SheetView sheetView1;
  131.     }
  132. }
复制代码


下面是Form的代码:
  1. using System;
  2. using System.Windows.Forms;

  3. namespace WindowsFormsApp2
  4. {
  5.     public partial class Form2 : Form
  6.     {
  7.         public Form2()
  8.         {
  9.             InitializeComponent();
  10.         }

  11.         private void Form2_Load(object sender, EventArgs e)
  12.         {
  13.             // 放开下句的注释即可解决IME和Focus问题
  14.             // this.sheetView1.SetActiveCell(0, 3);
  15.             this.fpSpread1.Select();
  16.         }

  17.         private void fpSpread2_Enter(object sender, EventArgs e)
  18.         {
  19.             this.sheetView1.SetActiveCell(0, 3);
  20.         }

  21.         private void fpSpread1_Enter(object sender, EventArgs e)
  22.         {
  23.             this.fpSpread1_Sheet1.SetActiveCell(0, 3);
  24.         }
  25.     }
  26. }
复制代码
回复 使用道具 举报
瑚边
注册会员   /  发表于:2019-3-26 15:40:39
地板
dexteryao 发表于 2019-3-26 11:10
其实您是为了解决不能focus的列被foucus的问题。
我这边测试了,从别的控件再点回spread,也无法选中列, ...

不能focus的列被focus的问题只会在这个Spread控件内其他可focus列没有被点击过才会出现,一旦点过其他可以focus的列,焦点就不会再次去到不能focus的那一列上了,除非画面重新load。
回复 使用道具 举报
瑚边
注册会员   /  发表于:2019-3-26 15:41:30
5#
另外补充一点,我是在日文系统里运行的。
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2019-3-26 16:20:32
6#
瑚边 发表于 2019-3-26 15:40
不能focus的列被focus的问题只会在这个Spread控件内其他可focus列没有被点击过才会出现,一旦点过其他可 ...

那是不是可以在页面加载时候就将activecell设置到第一个可以点击的单元格上,这样就不需要enter中做了。也就不存在后面的问题了。

因为我这边没有日文环境,不是很好完全重现这个问题。
回复 使用道具 举报
瑚边
注册会员   /  发表于:2019-3-26 16:31:37
7#
dexteryao 发表于 2019-3-26 16:20
那是不是可以在页面加载时候就将activecell设置到第一个可以点击的单元格上,这样就不需要enter中做了。 ...

是的。。在FormLoad事件里将ActiveCell设到可以点击的单元格上,就不需要Enter了,但是如果有多个Spread的话,就需要给每一个Spread都设一次ActiveCell,最后再设定初期的focus控件,否则当用户点击其他Spread的时候,还是会出现问题。只不过这样的代码看起来会比较怪。。
日文的话。。可以试试追加一个日文输入法来再现。。我感觉IME的问题跟这个环境无关。。
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2019-3-26 17:09:04
8#

我建议是从开始就设置好,后面也用在每次都变了。一个初始化设置也是合理的。
另外,我在中文系统下用日文输入法没重现出问题。
ime.mov (14.86 MB, 下载次数: 89)
回复 使用道具 举报
瑚边
注册会员   /  发表于:2019-3-26 18:48:32
9#
看了一下操作,感觉不太一样。
在现象中我描述过:画面上有两个Spread,两个Spread结构相同,只有1行4列,其中前3列Canfocus为FALSE,只有第四列可以编辑,ImeMode设定为Hiragana。两个Spread都绑定了Enter事件。

而我之所以要加Enter事件原因是,焦点的迁移是通过点击无数据的空白区域迁移的,也是因为这个原因,如果不做任何处理,焦点会跑到第一列不可以focus的地方去。
然后两个Spread中都只有一个Cell可以编辑。下方的Spread中同样设定了IME,而且出问题的正是下面这个Spread,上方的Spread反而是好的。
正是由于同样的设定,一个好一个不好,我才会觉得在画面加载的时候去强行设置ActiveCell才能解决问题比较奇怪。
在3楼我贴了我的代码。你可以用这个代码试试看。当然也不排除确实是系统差异导致了再现不了。

另外,初始化设置确实是合理的,但是由于本来初期的焦点就不在下面的Spread里,为了让下面的Spread在用户操作过程中不出现问题而追加初期的焦点设定就感觉不是很合理了。况且这样设定之后,还必须在最后再加一个初期的焦点设定,将初期焦点设回原本需求的位置(上方的Spread)。这种反复设置焦点的处理总觉得像在打补丁。如果一个画面上有十几个Spread(不用怀疑,确实有这样的画面),那么这样的焦点设定就得写十几次才能避免我说的现象。这样看的话,还是有点不友好吧。

比较遗憾的是,由于不方便录屏无法把现象直观的展现出来。不过还是很感谢你的解答和调查。
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2019-3-27 11:36:07
10#
问题我重现了,是比较奇怪,我会反馈开发看看什么原因,有没有更好的办法。
回复 使用道具 举报
12下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部