- - PR -
FlexGridでセルのプロパティ変更
1
投稿者 | 投稿内容 |
---|---|
|
投稿日時: 2005-08-02 18:18
Form_Load時にグリッド内のデータによって、特定セルの入力抑制を
したいのですが、よい方法はないでしょうか? とりあえずこんな感じです。。 ///////////// for ( int i = 1; i <= this.Grid1.Rows.Count - 1; i++ ) { int s = this.Grid1.Cols["A"].Index; if ( InputChecker.CheckNotNull( this.Grid1.GetData(i,"B").ToString().Trim() ) ) { C1.Win.C1FlexGrid.CellRange cg = new C1.Win.C1FlexGrid.CellRange(); cg = this.Grid1.GetCellRange( i, s, i, s ); cg.Data = string.Empty; cg.Style = this.Grid1.Styles ["Fixed"]; this.Grid1.Cols["A"].AllowEditing = false; } else { // } } /////////// Grid1のセル"B"に何かSETされていれば、セル"A"をCellRangeプロパティで 外観だけStyleを設定できますが、編集プロパティを制御できません。 this.Grid1.Cols["A"].AllowEditing = false; とすると全部のCols["A"]が編集不可になります。 同じ行のCols["A"]だけを編集不可にしたいのですが、方法は ありますでしょうか。 |
|
投稿日時: 2005-08-03 15:35
もう必要ないかもしれませんが
StartEditイベントで CellStyle cs = Grid1.GetCellStyle(e.Row, e.Col); e.Cancel = (cs.Name == "Fixed"); ではどうでしょう? |
|
投稿日時: 2005-08-04 13:38
to ghornetyさん。ありがとうございます。
GrapeCityのQAでそれらしいのがあるようです。 どうやら、Grid1にSETする前にBeforeEditプロパティに追加すれば いいようです。StartEditでも同様の結果ですね。 // private void Grid1_BeforeEdit(object sender, C1.Win.C1FlexGrid.RowColEventArgs e) { if ( this.Grid1.Cols["A"].Index == e.Col ) { //ここでBセルに値がなければAセルを編集不可にする if ( this.Grid1[ e.Row, "B" ].ToString().Trim().Length != 0 ) { e.Cancel = true; return; } } } // ありがとうございました。 |
|
投稿日時: 2005-08-04 14:32
ご存知かもしれませんが、
BeforeEditイベントは常に、再描画前に(編集後にも)発生するようです。 必ず編集モードに切り替わるタイミングはStartEditイベントみたいです。 # 今回の様な処理はどちらのタイミングでも良いと思いますが... |
1