public CellDrawer(Forms::DataGridView sender, Forms::DataGridViewCellPaintingEventArgs e) { this.sender = sender; this.e = e; this.data = this.sender.Rows[e.RowIndex].DataBoundItem as SshUserData; this.selected = 0 != (e.State & Forms::DataGridViewElementStates.Selected); this.isvalid = true; this.cBack = default(Gdi::Color); this.cFore = default(Gdi::Color); this.text = null; }
//OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO // セルの描画 //-------------------------------------------------------------------------- void dataGridView1_CellPainting(object sender, Forms::DataGridViewCellPaintingEventArgs e) { if (e.RowIndex < 0) { return; } CellDrawer drawer = new CellDrawer(this.gridGwchain, e); if (e.ColumnIndex == 0) { if (e.Value == null) { drawer.text = e.CellStyle.NullValue.ToString(); } else { drawer.text = (string)e.Value; if (drawer.data != null && !drawer.data.FullnameForEditIsValid) { drawer.text += " <形式が間違っています>"; drawer.isvalid = false; } } drawer.DetermineColor(); drawer.Draw(); e.Handled = true; } else if (e.ColumnIndex == 1) { if (e.Value == null || (string)e.Value == "") { drawer.text = e.CellStyle.NullValue.ToString(); } else { gridGwchain.Rows[e.RowIndex].Cells[1].ToolTipText = "<パスワード>"; drawer.text = new string('*', ((string)e.Value).Length); } drawer.DetermineColor(); drawer.Draw(); e.Handled = true; } }