SORU
8 EYLÜL 2010, ÇARŞAMBA


Hangi CheckedListBox olay bir madde işaretli sonra tetikler?

Bir olay istediğim bir CheckedListBox varsonrabir öğeyi yeni devlet ile Checkedİtems kullanabilmesi için kontrol edilir.

İtemChecked Checkedİtems güncellenir önce ateş olduğu için kutunun dışında çalışmaz.

Nasıl bir yöntem veya olay Checkedİtems güncelleme olduğunda haberdar olmak için kullanabilir miyim?

CEVAP
8 EYLÜL 2010, ÇARŞAMBA


Eğer siz de tıkladım ediliyor öğe yeni durumunu kontrol edin ItemCheck olay kullanabilirsiniz. Bu olay mevcut, e.NewValue olarak çalışmaz. NewValue işaretli ise, toplama ile birlikte, geçerli öğe vardır, uygun bir mantık

    private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)
    {                     
        List<string> checkedItems = new List<string>();
        foreach (var item in checkedListBox1.CheckedItems)
            checkedItems.Add(item.ToString());

        if (e.NewValue == CheckState.Checked)
            checkedItems.Add(checkedListBox1.Items[e.Index].ToString());

        foreach (string item in checkedItems)
        {
            ...
        }
    }

Başka bir örnek olarak, eğer toplama bu madde sonra boş olacaktır olmadığını belirlemek için (un)teslim tarihi:

private void ListProjects_ItemCheck(object sender, ItemCheckEventArgs args)
{
    if (ListProjects.CheckedItems.Count == 1 && args.NewValue == CheckState.Unchecked)
        // The collection is about to be emptied: there's just one item checked, and it's being unchecked at this moment
        ...
    else
        // The collection will not be empty once this click is handled
        ...
}

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Bart Baker

    Bart Baker

    1 Aralık 2006
  • makemebad35

    makemebad35

    17 NİSAN 2006
  • Qmusic Romania

    Qmusic Roman

    8 Temmuz 2011