2013-04-19 2 views
3

두 개의 그리드가있는 마스터 세부 양식이 있습니다. customers = master, orders = detail. 마스터 그리드에서 새 고객을 선택할 때 세부 사항을 새로 고치는 방법은 무엇입니까? 여기 내 코드입니다 :선택한 마스터 항목이 변경되면 세부 사항을 새로 고치는 방법은 무엇입니까?

public partial class Form1 : Form 
    { 
     AutoLotEntities context = new AutoLotEntities(); 
     BindingSource customerBindingSource; 
     BindingSource orderBindingSource; 

     public Form1() 
     { 
      InitializeComponent(); 
     } 

     private void Form1_Load(object sender, EventArgs e) 
     { 
      customerBindingSource = new BindingSource(); 
      orderBindingSource = new BindingSource(); 

      customerBindingSource.DataSource = context.Customers; 
      orderBindingSource.DataMember = "Orders"; 
      orderBindingSource.DataSource = customerBindingSource.DataSource; 

      grdCustomers.DataSource = customerBindingSource; 
      grdOrders.DataSource = orderBindingSource; 
     } 
    } 

내가 IDE의 도움으로 그것을 할 관리하는 Form1.Desginer.cs에서 코드를 생성하지만 어떻게이 일의 작품을 볼 수 비 생성 된 코드와 손으로 작업을 수행 할 .

답변

0

Customers를 컨텍스트로 사용하여 주.에 대한 눈금을 생성하는 메소드를 작성하십시오. 그런 다음 다른 매개 변수 (예 : 고객 ID)를 받아들이고 데이터 격자를 다시로드하는 재정의 된 메소드를 작성하십시오.

관련 문제