ListBox Selected Items Method

28.04.2011
Method listbox ve type parametresi alır. Listbox' tan seçilen itemların value değerlerini, 
1,2,3 veya '1','2', '3' şeklinde geri döndürür. 

private string sLbArray(ListBox lb, Type type)
        {
            string IDs = "";
            if (type == typeof(string))
            {
                foreach (int item in lb.GetSelectedIndices())
                {
                    IDs += "'" + lb.Items[item].Value + "',";
                }
            }
            else if (type == typeof(int))
            {
                foreach (int item in lb.GetSelectedIndices())
                {
                    IDs += lb.Items[item].Value + ",";
                }
            }
            return IDs.TrimEnd(',');
        }

0 kişi tarafından 0 olarak değerlendirildi

  • Currently 5.0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

, ,

Yorumlar

Yorum ekle




  • Yorum

Lütfen aşağıdaki kutuya yandaki sayısı yazınız: --> 2