作成日: 2017/07/26 最終更新日: 2017/07/26
文書種別
使用方法
詳細
文字列型セル(TextBoxCell)やマスク型セル(MaskedTextBoxCell)でPasswordCharプロパティを使用してパスワード文字を有効にしたとき、実行時にユーザーがこのセルをコピーしようとすると次のエラーメッセージが表示されます。
このエラーは、TextBoxコントロールで同様の操作を行う場合や、DataGridViewコントロールで同様の操作を行う場合と同じように、セキュリティ上の理由から提供されています。
このメッセージを非表示にし、任意の方法で表示するには、次のようにコーディングします。
[Visual Basic]
[C#]
--------------------------- GcMultiRow の既定のエラー ダイアログ --------------------------- GcMultiRow で次の例外が発生しました: System.InvalidOperationException: 実行時にパスワード付きのセルをコピーすることはできません。 この既定のダイアログを置き換えるには、DataError イベントをハンドルしてください。
このエラーは、TextBoxコントロールで同様の操作を行う場合や、DataGridViewコントロールで同様の操作を行う場合と同じように、セキュリティ上の理由から提供されています。
このメッセージを非表示にし、任意の方法で表示するには、次のようにコーディングします。
[Visual Basic]
Imports GrapeCity.Win.MultiRow
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim textBoxCell1 As New TextBoxCell()
textBoxCell1.PasswordChar = "*"
GcMultiRow1.Template = Template.CreateGridTemplate(New Cell() {textBoxCell1})
End Sub
Private Sub GcMultiRow1_DataError(ByVal sender As System.Object, ByVal e As GrapeCity.Win.MultiRow.DataErrorEventArgs) Handles GcMultiRow1.DataError
Dim gcMultiRow As GcMultiRow = TryCast(sender, GcMultiRow)
If TypeOf e.Exception Is InvalidOperationException Then
If TypeOf gcMultiRow(e.RowIndex, e.CellIndex) Is TextBoxCell Then
Dim textBoxCell As TextBoxCell = TryCast(gcMultiRow(e.RowIndex, e.CellIndex), TextBoxCell)
If textBoxCell.UseSystemPasswordChar = True OrElse String.IsNullOrEmpty(textBoxCell.PasswordChar) = False Then
e.ThrowException = False
Console.WriteLine(e.Exception.Message)
End If
End If
End If
End Sub
[C#]
using GrapeCity.Win.MultiRow;
private void Form1_Load(object sender, EventArgs e)
{
TextBoxCell textBoxCell1 = new TextBoxCell();
textBoxCell1.PasswordChar = '*';
gcMultiRow1.Template = Template.CreateGridTemplate(new Cell[] { textBoxCell1 });
gcMultiRow1.DataError +=new EventHandler<DataErrorEventArgs>(gcMultiRow1_DataError);
}
private void gcMultiRow1_DataError(object sender, DataErrorEventArgs e)
{
GcMultiRow gcMultiRow = sender as GcMultiRow;
if (e.Exception is InvalidOperationException)
{
if (gcMultiRow.Rows[e.RowIndex].Cells[e.CellIndex] is TextBoxCell)
{
TextBoxCell textBoxCell1 = gcMultiRow.Rows[e.RowIndex].Cells[e.CellIndex] as TextBoxCell;
if (textBoxCell1.UseSystemPasswordChar == true || string.IsNullOrEmpty(textBoxCell1.PasswordChar.ToString()) == false)
{
e.ThrowException = false;
Console.WriteLine(e.Exception.Message);
}
}
}
}
旧文書番号
40516