我找到了一个办法解决IME的问题。。在Form_Load事件里把出问题的Spread的备考栏先设成ActiveCell。。然后再设置原本初期的Focus控件。。这样画面表示后IME也正常了。。不能Focus的列被Focus的问题也解决了。。连RowEnter事件都不用加了。。尽管问题解决了。。可我还是觉得这个现象比较像个BUG。。。
以下是Designer的代码:
- namespace WindowsFormsApp2
- {
- partial class Form2
- {
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.IContainer components = null;
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
- #region Windows Form Designer generated code
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- FarPoint.Win.Spread.CellType.TextCellType textCellType9 = new FarPoint.Win.Spread.CellType.TextCellType();
- FarPoint.Win.Spread.CellType.TextCellType textCellType10 = new FarPoint.Win.Spread.CellType.TextCellType();
- this.fpSpread1 = new FarPoint.Win.Spread.FpSpread();
- this.fpSpread1_Sheet1 = new FarPoint.Win.Spread.SheetView();
- this.fpSpread2 = new FarPoint.Win.Spread.FpSpread();
- this.sheetView1 = new FarPoint.Win.Spread.SheetView();
- ((System.ComponentModel.ISupportInitialize)(this.fpSpread1)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.fpSpread1_Sheet1)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.fpSpread2)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.sheetView1)).BeginInit();
- this.SuspendLayout();
- //
- // fpSpread1
- //
- this.fpSpread1.AccessibleDescription = "fpSpread1, Sheet1, Row 0, Column 0, ";
- this.fpSpread1.Location = new System.Drawing.Point(28, 12);
- this.fpSpread1.Name = "fpSpread1";
- this.fpSpread1.Sheets.AddRange(new FarPoint.Win.Spread.SheetView[] {
- this.fpSpread1_Sheet1});
- this.fpSpread1.Size = new System.Drawing.Size(472, 61);
- this.fpSpread1.TabIndex = 0;
- this.fpSpread1.Enter += new System.EventHandler(this.fpSpread1_Enter);
- //
- // fpSpread1_Sheet1
- //
- this.fpSpread1_Sheet1.Reset();
- this.fpSpread1_Sheet1.SheetName = "Sheet1";
- // Formulas and custom names must be loaded with R1C1 reference style
- this.fpSpread1_Sheet1.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.R1C1;
- this.fpSpread1_Sheet1.ColumnCount = 4;
- this.fpSpread1_Sheet1.RowCount = 1;
- this.fpSpread1_Sheet1.Cells.Get(0, 0).CanFocus = false;
- this.fpSpread1_Sheet1.Cells.Get(0, 1).CanFocus = false;
- this.fpSpread1_Sheet1.Cells.Get(0, 2).CanFocus = false;
- this.fpSpread1_Sheet1.Cells.Get(0, 3).CellType = textCellType9;
- this.fpSpread1_Sheet1.Cells.Get(0, 3).ImeMode = System.Windows.Forms.ImeMode.Hiragana;
- this.fpSpread1_Sheet1.ColumnFooterSheetCornerStyle.HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.General;
- this.fpSpread1_Sheet1.ColumnFooterSheetCornerStyle.NoteIndicatorColor = System.Drawing.Color.Red;
- this.fpSpread1_Sheet1.ColumnFooterSheetCornerStyle.Parent = "CornerDefaultEnhanced";
- this.fpSpread1_Sheet1.ColumnFooterSheetCornerStyle.VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.General;
- this.fpSpread1_Sheet1.Columns.Get(0).BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
- this.fpSpread1_Sheet1.Columns.Get(1).BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
- this.fpSpread1_Sheet1.Columns.Get(2).BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
- this.fpSpread1_Sheet1.RowHeader.Columns.Default.Resizable = false;
- this.fpSpread1_Sheet1.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.A1;
- //
- // fpSpread2
- //
- this.fpSpread2.AccessibleDescription = "fpSpread2, Sheet1, Row 0, Column 0, ";
- this.fpSpread2.Location = new System.Drawing.Point(28, 111);
- this.fpSpread2.Name = "fpSpread2";
- this.fpSpread2.Sheets.AddRange(new FarPoint.Win.Spread.SheetView[] {
- this.sheetView1});
- this.fpSpread2.Size = new System.Drawing.Size(472, 61);
- this.fpSpread2.TabIndex = 1;
- this.fpSpread2.Enter += new System.EventHandler(this.fpSpread2_Enter);
- //
- // sheetView1
- //
- this.sheetView1.Reset();
- this.sheetView1.SheetName = "Sheet1";
- // Formulas and custom names must be loaded with R1C1 reference style
- this.sheetView1.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.R1C1;
- this.sheetView1.ColumnCount = 4;
- this.sheetView1.RowCount = 1;
- this.sheetView1.Cells.Get(0, 0).BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
- this.sheetView1.Cells.Get(0, 0).CanFocus = false;
- this.sheetView1.Cells.Get(0, 1).BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
- this.sheetView1.Cells.Get(0, 1).CanFocus = false;
- this.sheetView1.Cells.Get(0, 2).BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
- this.sheetView1.Cells.Get(0, 2).CanFocus = false;
- this.sheetView1.Cells.Get(0, 3).CellType = textCellType10;
- this.sheetView1.Cells.Get(0, 3).ImeMode = System.Windows.Forms.ImeMode.Hiragana;
- this.sheetView1.ColumnFooterSheetCornerStyle.HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.General;
- this.sheetView1.ColumnFooterSheetCornerStyle.NoteIndicatorColor = System.Drawing.Color.Red;
- this.sheetView1.ColumnFooterSheetCornerStyle.VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.General;
- this.sheetView1.FilterBarHeaderStyle.HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.General;
- this.sheetView1.FilterBarHeaderStyle.NoteIndicatorColor = System.Drawing.Color.Red;
- this.sheetView1.FilterBarHeaderStyle.VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.General;
- this.sheetView1.RowHeader.Columns.Default.Resizable = false;
- this.sheetView1.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.A1;
- //
- // Form2
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(800, 450);
- this.Controls.Add(this.fpSpread2);
- this.Controls.Add(this.fpSpread1);
- this.Name = "Form2";
- this.Text = "Form2";
- this.Load += new System.EventHandler(this.Form2_Load);
- ((System.ComponentModel.ISupportInitialize)(this.fpSpread1)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.fpSpread1_Sheet1)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.fpSpread2)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.sheetView1)).EndInit();
- this.ResumeLayout(false);
- }
- #endregion
- private FarPoint.Win.Spread.FpSpread fpSpread1;
- private FarPoint.Win.Spread.SheetView fpSpread1_Sheet1;
- private FarPoint.Win.Spread.FpSpread fpSpread2;
- private FarPoint.Win.Spread.SheetView sheetView1;
- }
- }
复制代码
下面是Form的代码:
- using System;
- using System.Windows.Forms;
- namespace WindowsFormsApp2
- {
- public partial class Form2 : Form
- {
- public Form2()
- {
- InitializeComponent();
- }
- private void Form2_Load(object sender, EventArgs e)
- {
- // 放开下句的注释即可解决IME和Focus问题
- // this.sheetView1.SetActiveCell(0, 3);
- this.fpSpread1.Select();
- }
- private void fpSpread2_Enter(object sender, EventArgs e)
- {
- this.sheetView1.SetActiveCell(0, 3);
- }
- private void fpSpread1_Enter(object sender, EventArgs e)
- {
- this.fpSpread1_Sheet1.SetActiveCell(0, 3);
- }
- }
- }
复制代码 |