muratboy31 Posted December 2, 2015 Share Posted December 2, 2015 Arkadaşlar, kod ile oluşturduğum Tablar içerisinde aynı şekilde kod ile oluşturduğum Listboxlar var, veri tabından verilerimi bu listboxlara çekiyorum buraya kadar sorun yok ancak çok fazla veri olduğunda işlem çok uzun sürüyor.. acaba sadece aktif tabdaki listbox verilerini nasıl çekebilirim. Tab ve Listbox isimleride code tarafında oluşturuluyor... tabindex change olayında da aktif olan liste verilerini çeksin istiyorum ; aşağıdaki kod ile tümverileri çekip bir kerede bütün lüstboxlara doldurabiliyorum ancak baya uzun zaman alıyor ; using (WebClient client = new WebClient()) { string ofis = GetPageSource("http://172.16.0.6/rehber/rehber_ofis.php"); List<Office> Officess = JsonConvert.DeserializeObject<List<Office>>(System.Text.Encoding.UTF8.GetString(System.Convert.FromBase64String(ofis))); string personel = GetPageSource("http://172.16.0.6/rehber/rehber_search.php?txtKeyword=" + base64encode("")); List<Employee> Employees = JsonConvert.DeserializeObject<List<Employee>>(System.Text.Encoding.UTF8.GetString(System.Convert.FromBase64String(personel))); foreach (Office Office in Officess) { int L_OfficeID = Office.OfficeID; string L_OfficeName = Office.OfficeName.ToString(); SuperTabItem tab = superTabControl1.CreateTab(L_OfficeName); tab.Name = L_OfficeID.ToString(); SuperTabControlPanel panel = (SuperTabControlPanel)tab.AttachedControl; ListBoxAdv listBox = new ListBoxAdv() { Name = "lb_Employee_" + Convert.ToString(L_OfficeID) }; listBox.Dock = DockStyle.Fill; listBox.ItemHeight = 40; listBox.BackgroundStyle.Class = "ListBoxAdv"; listBox.AutoScroll = true; listBox.SelectedIndexChanged += new System.EventHandler(listBox_SelectedIndexChanged); panel.Controls.Add(listBox); var result = Employees.Where(a => a.OfficeID == L_OfficeID); foreach (var r in result) { ListBoxItem item = new ListBoxItem(); item.Text = "<b>" + r.FirstName.ToString() + " " + r.Surname.ToString() + "</b><br><font color='#ED1C24'>" + r.Title.ToString() + "</font></br>"; item.HotTracking = true; item.Tag = r.EmployeeID.ToString(); listBox.Items.Add(item); } } } Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted December 2, 2015 Editor Share Posted December 2, 2015 listbox lara uniq ID ekleyip aktif tabdaki kontrolleri listeleyip çekebilirsiniz. Quote Link to comment Share on other sites More sharing options...
muratboy31 Posted December 3, 2015 Author Share Posted December 3, 2015 aslında zaten uniq name veriyorum ; ama aktif tabdaki controlleri çekemedim, ListBoxAdv listBox = new ListBoxAdv() { Name = "lb_Employee_" + Convert.ToString(L_OfficeID) }; Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted December 3, 2015 Editor Share Posted December 3, 2015 (edited) Dinamik olarak tablara listbox ekliyorum. foreach (TabPage tPage in tabControl1.TabPages) { ListBox tListbox = new ListBox() { Name = "Listbox" }; tPage.Controls.Add(tListbox); tListbox.Dock = DockStyle.Fill; } Daha sonra tabcontrol ün selected eventını yakalayarak aktif tabdaki listbox ın ismine göre değer ekledim. Event adı tabcontrol1_Selected foreach (Control c in e.TabPage.Controls) { if (c.Name == "Listbox") { for (int i = 0; i < 10; i++) { var nListBox = (ListBox)c; nListBox.Items.Add(i); } } } Edited December 3, 2015 by pairs Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.