private void ComboBoxTenant_SelectedIndexChanged(object sender, EventArgs e) { LeaseDA leaseDA = new LeaseDA(); Tenant selectedTenant = (Tenant)ComboBoxTenant.SelectedItem; List <LeaseLand> leaseLand = leaseDA.GetLeaseLandByTenantID(selectedTenant.TenantID); ComboBoxLeaseLand.DataSource = leaseLand; ComboBoxLeaseLand.DisplayMember = "LandInfo"; ComboBoxLeaseLand.ValueMember = "LeaseID"; }
private void PopulateLeasedLands() { try { // Retrieve the TenantID DataGridViewRow selectedTenant = DataGridViewTenants.CurrentRow; int tenantID = int.Parse(selectedTenant.Tag.ToString()); LeaseDA leaseDA = new LeaseDA(); List <LeaseLand> leasedLands = leaseDA.GetLeaseLandByTenantID(tenantID); ListBoxLeasedLands.DataSource = leasedLands; ListBoxLeasedLands.DisplayMember = "LandInfo"; ListBoxLeasedLands.ValueMember = "LeaseID"; } catch (Exception) { MessageForm messageForm = new MessageForm(); messageForm.MessageText = "केहीको प्राविधिक कारणले गर्दा कार्य सम्पन्न गर्न सकिएन।"; messageForm.ShowDialog(); } }