0

プロジェクトに編集ボタンがあり、リストボックスの行を編集できますが、編集可能にしたくない特定の行があります。どうすればそれを可能にできますか?

4、9、14、19、24、29、34、39、44、49、54、59、64、69、74、79、84、89、94、99行目を編集不可にしたい。

applicationdate 行を編集不可にしたいのですが、そのコード行を編集不可にする方法はありますか。

4

2 に答える 2

0

SelectedIndexChangedイベントを処理します。このイベントは、ListBoxコントロール内の項目の選択が変更されるたびに発生します。

このイベントのイベント ハンドラー メソッド内で、現在選択されている項目のインデックスを確認します。編集を許可したい場合は、[編集] ボタンを有効にします。それ以外の場合は、[編集] ボタンを無効にします。

例えば:

Private Sub myListBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles myListBox.SelectedIndexChanged
    ' Only allow editing of items with an odd-numbered index.
    ' (This isn't very useful, just a demonstration. You can use any criteria you
    '  want to determine whether editing should be allowed for the current item.)
    btnEdit.Enabled = myListBox.SelectedIndex Mod 2
End Sub
于 2012-08-12T08:00:23.810 に答える
-1
Private Sub myListBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles myListBox.SelectedIndexChanged
    ' Only allow editing of items with an odd-numbered index.
    ' (This isn't very useful, just a demonstration. You can use any criteria you
    '  want to determine whether editing should be allowed for the current item.)
    Dim unedit() as integer={4, 9, 14, 19, 24, 29, 34, 39, 44, 49, 54, 59, 64, 69, 74, 79, 84, 89, 94, 99}
    dim i as integer
    for i = 0 unedit.count-1
    if myListBox.SelectedIndex=unedit(i) then
       btnEdit.Enabled = false
       exit for
    end if
End Sub
于 2012-08-12T09:07:20.140 に答える