Jump to content

Kod Ile Oluştutulmuş Controller


muratboy31
 Share

Recommended Posts

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);
                        }
                        
                    }
                }
Link to comment
Share on other sites

  • Editor

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 by pairs
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...