C#

初めてのC# ~ 覚え書き ~

○警告:XMLコメントがありませんを非表示にする

プロジェクトのプロパティ→ビルド→XMLドキュメントファイルのファイル名を空にする

○ToolStrip等のプロパティが継承先フォームでグレーアウトになる
参照設定にSystem.Design.dllを追加する。ただし継承先でボタンの追加等はできなかった。

[System.ComponentModel.Designer(typeof(System.Windows.Forms.Design.ControlDesigner))]
public partial class ToolStripBase : System.Windows.Forms.ToolStrip
{
	public ToolStripBase()
	{
		InitializeComponent();
	}
}

○型判定
if (obj is Button)

○TextBoxで数値のみ許可する(練習)

  private void gridDetail_SetupEditor(object sender, RowColEventArgs e)
        {
            C1FlexGrid grid = (C1FlexGrid)sender;

                Control o = grid.Editor;
                o.KeyPress += delegate (object obj, KeyPressEventArgs ee)
                {
                    if (ee.KeyChar == '\b') return; //BackSpaceは許可

                    TextBox ctl = (TextBox)obj;
                    string s = ctl.Text.Substring(0, ctl.SelectionStart);
                    s += ee.KeyChar;
                    s += ctl.Text.Substring(ctl.SelectionStart + ctl.SelectionLength);

                    //整数のみ入力可とする
                    int i;
                    if (int.TryParse(s, out i) == false) { ee.Handled = true; return; }

                    // 0~99999999まで入力可とする
                    if (i  99999999) { ee.Handled = true; return; }

                    //if ((i * 10) > 100)
                    //{
                    //    //gridList.editm
                    //    //gridList[gridList.Row, gridList.Col] = i.ToString();
                    //    //gridList.FinishEditing(true);
                    //    //gridList[gridList.Row, gridList.Col] = i.ToString();
                    //    //ee.Handled = true;
                    //    gridList.Col = gridList.Cols[CGridTable.enumColAttrConst.Up_date0.ToString()].Index;
                    //    return;
                    //}

                };
            
        }