2014-09-27 4 views
1

C#WinForms 응용 프로그램에서 DataGridView을 사용하고 있고 사용자가 각 셀에서 동일한 값 집합 중에서 하나를 선택할 수 있도록하려고합니다. 모든 셀에 값 목록을 채우는 방법이 필요하다고 가정합니다.DataGridViewCombobBoxColumn에 값을 채우는 방법

GUI 디자이너를 사용하여 COL_BUSINESS_INDUSTRY (DataGridViewComboBoxColumn)을 DataGridView에 추가했습니다. idindustryName

두 fiels을 가지고있는 DataTable를 반환합니다

COL_BUSINESS_INDUSTRY.DataSource = LoadIndustries(); 
COL_BUSINESS_INDUSTRY.DataPropertyName = "industryName"; 
COL_BUSINESS_INDUSTRY.DisplayMember = COL_BUSINESS_INDUSTRY.DataPropertyName; 
COL_BUSINESS_INDUSTRY.ValueMember = COL_BUSINESS_INDUSTRY.DataPropertyName; 

LoadIndustries() : 생성자에서, 내가하는 나는 다음과 같은 코드를 사용하고, 값 목록으로 선택 상자를 채우려 문제는 내가 이것을 실행할 때 ComboBoxes에 값이 없다는 것입니다.

LoadIndustries()이 으로 설정하지 않고 List<string>을 반환하려고했으나 작동하지 않았습니다. 나는 또한 List<string>을 반환 LoadIndustries()으로,이 일을 시도

,하지만 여전히 운 :

COL_BUSINESS_INDUSTRY.Items.AddRange(); 

는 분명 내가 뭔가를 잘못하고 있어요하지만 온라인으로 보는 3 시간 이상 지났는데 내가 아무 생각이 없습니다. 왜 내 콤보 상자에 값이 표시되지 않습니까?

편집 :

추가에게 다음 클래스를 값 포함 :

class IndustryObj 
{ 
    public string theString { get; set; } 
    public string theId { get; set; } 
    public IndustryObj(string id, string s) { theId = id; theString = s; } 
    public override string ToString() { return theString; } 
} 

나는를 TAW의 제안에 따라, 나는 여전히 작동하지 않는 다음과 같은 변화를했습니다 다음의 방법으로 산업을 적재한다. 나는 개체의 값을로드하는 것은 잘 작동하고 있음을 보장 할 수 있습니다 :

private static List<IndustryObj> LoadIndustries() 
{ 
    var industries = new List<IndustryObj>(); 

    const string sql = "SELECT id, name FROM Industry ORDER BY name"; 
    using (var sqlQuery = new CustomSqlQuery(MyDatabases.Telemarketing, sql)) 
    { 
     foreach (var record in sqlQuery) 
     { 
      industries.Add(new IndustryObj(record[0].ToString(), record[1].ToString())); 
     } 
    } 

    return industries; 
} 

이 내가 DataGridView를 채우기하고있는 방법이다. 모든 값은 COL_BUSINESS_INDUSTRY에있는 사람을 제외하고, 미세로드 :

private void LoadBusinesses() 
{ 
    COL_BUSINESS_INDUSTRY.DataSource = LoadIndustries(); 
    COL_BUSINESS_INDUSTRY.DataPropertyName = "theString"; 
    COL_BUSINESS_INDUSTRY.DisplayMember = COL_BUSINESS_INDUSTRY.DataPropertyName; 
    COL_BUSINESS_INDUSTRY.ValueMember = "theId"; 

    const string sql = "SELECT id, company, contact, address, phone, email, status, industry, callbackDate, callbackTime, createdBy, lastUpdatedBy, lockedUntil FROM Business ORDER BY company"; 
    using (var sqlQuery = new CustomSqlQuery(MyDatabases.Telemarketing, sql)) 
    { 
     var columns = new DataGridViewColumn[] 
      { 
       COL_BUSINESS_COMPANY, 
       COL_BUSINESS_CONTACT, 
       COL_BUSINESS_ADDRESS, 
       COL_BUSINESS_PHONE, 
       COL_BUSINESS_EMAIL, 
       COL_BUSINESS_STATUS, 
       COL_BUSINESS_INDUSTRY, 
       COL_BUSINESS_CALLBACKDATE, 
       COL_BUSINESS_CALLBACKTIME, 
       COL_BUSINESS_CREATEDBY, 
       COL_BUSINESS_LASTUPDATEDBY, 
       COL_BUSINESS_LOCKEDUNTIL 
      }; 

     foreach (var record in sqlQuery) 
     { 
      dgv_Businesses.Rows.Add(CustomDGVRow.InitializeFromDataReader(true, record, columns)); 
     } 
    } 
} 

편집 2 : TAW의 두 번째 제안에 따라, 나는 다음과 같은 일을했습니다. 3

private List<IndustryObj> industryObjects; 
private void LoadBusinesses() 
{ 
    industryObjects = LoadIndustries(); 
    COL_BUSINESS_INDUSTRY.DataSource = industryObjects; 
    COL_BUSINESS_INDUSTRY.DataPropertyName = "theString"; 
    COL_BUSINESS_INDUSTRY.DisplayMember = COL_BUSINESS_INDUSTRY.DataPropertyName; 
    COL_BUSINESS_INDUSTRY.ValueMember = "theId"; 
... 

편집 : 이것은 도움이되지 않았다 Luminous 실제로 그것을 가지고,하지만 그건 다른 문제의 번호를 소개합니다. 로딩 방법은 지금과 같다 : 당신이 볼 수 있듯이

private void LoadBusinesses() 
{ 
    // Load the records. 
    const string sql = 
     "SELECT id, company, contact, address, phone, email, status, industry, callbackDate, callbackTime, createdBy, lastUpdatedBy, lockedUntil FROM Business ORDER BY company"; 
    using (var sqlQuery = new CustomSqlQuery(MyDatabases.Telemarketing, sql)) 
    { 
     var columns = new DataGridViewColumn[] 
      { 
       COL_BUSINESS_COMPANY, 
       COL_BUSINESS_CONTACT, 
       COL_BUSINESS_ADDRESS, 
       COL_BUSINESS_PHONE, 
       COL_BUSINESS_EMAIL, 
       COL_BUSINESS_STATUS, 
       COL_BUSINESS_INDUSTRY, 
       COL_BUSINESS_CALLBACKDATE, 
       COL_BUSINESS_CALLBACKTIME, 
       COL_BUSINESS_CREATEDBY, 
       COL_BUSINESS_LASTUPDATEDBY, 
       COL_BUSINESS_LOCKEDUNTIL 
      }; 

     foreach (var record in sqlQuery) 
     { 
      dgv_Businesses.Rows.Add(CustomDGVRow.InitializeFromDataReader(true, record, columns)); 
     } 
    } 

    // Load the industries and bind the industry DataSource to the industry ComboBoxColumn. 
    COL_BUSINESS_INDUSTRY.DataSource = LoadIndustries(); 
    COL_BUSINESS_INDUSTRY.DataPropertyName = "theString"; 
    COL_BUSINESS_INDUSTRY.DisplayMember = COL_BUSINESS_INDUSTRY.DataPropertyName; 
    COL_BUSINESS_INDUSTRY.ValueMember = "theId"; 

    // Select the correct industries in the industry column. 
    foreach (var rawRow in dgv_Businesses.Rows) 
    { 
     var row = rawRow as CustomDGVRow; 
     if (row == null) continue; 

     foreach (var item in ((CustomDGVComboBoxCell) row.Cells[COL_BUSINESS_INDUSTRY.Index]).Items) 
     { 
      var industry = item as IndustryObj; 
      if (industry == null) continue; 

      if (row.Cells[COL_BUSINESS_INDUSTRY.Index].Value != null && industry.theId == row.Cells[COL_BUSINESS_INDUSTRY.Index].Value.ToString()) 
      { 
       row.Cells[COL_BUSINESS_INDUSTRY.Index].Value = industry; 
      } 
     } 
    } 
} 

, 나는 또한 데이터베이스에서 해당 ID를 기반으로 항목 목록에서 하나 개의 값을 선택해야합니다. 나는 (Luminous의 제안에 따라) 항목을로드 한 후에 만 ​​데이터 소스를 바인딩하기 때문에 행을 다른 패스로 전달하고 각 행에 올바른 산업 가치를 설정해야합니다. 그러나, 행 수가 매우 많기 때문에 이것은 매우 비쌉니다.

  1. 가 어떻게 올바른 값을 설정하는 또 다른 패스를 일을 피할 수 있습니다 : 그래서 수상 현상금을 위해, 나는 두 개의 추가 질문에 대한 답변을해야합니까?
  2. 왜 처음에는 행을로드 한 다음 데이터 소스 만 바인딩해야합니까? 이것은 다소 비현실적이며 내 문제를 일으킨다. 요구 사항으로 인해 초기로드 후 어느 시점에 더 많은 데이터가로드되도록 요청하면 어떻게됩니까? 바인딩을 다시해야합니까?
+0

_COL_BUSINESS_INDUSTRY.DataSource = LoadIndustries(); _이 컴파일합니까? 변수를 변수에 넣고 해당 변수에 데이터 소스를 설정하십시오. 필자는 시스템이 언제나 함수에서 가져와야하는 DataSource로 어떻게 작동하는지 상상할 수 없습니다 .. – TaW

+0

오류나 경고없이 컴파일됩니다. 나는 당신이 최신 편집에서 볼 수 있듯이 여전히 운이 없다 이것을 시도했다. 다른 아이디어? 나는 가능한 한 빨리 일할 필요가 있기 때문에이 현상금을 공개했다. –

+1

드롭 다운 열 imo 앞에 행을로드하는 것은 의미가 없습니다. 그 열 유형의 요점은 가치있는 안전한 입력 및 편집을 허용하는 것입니다. 다른 잘못된 것이 있어야합니다. – TaW

답변

1

당신이 설명 할 필요가 우선이다 checkboxcolumn 및 comboboxcolumn 아닌가요? 그것은 당신의 모든 문제 일 수 있습니다.

이제 귀하의 코드로 귀하는 가능한 업계로 이미 채워진 목록을 보유하게됩니다. 행을 만들지 않으면 튜플 (행)에 어떻게 데이터 바인딩을 할 것인가? dgv를 쿼리 결과로 채운 후에는 열의 모든 셀을 데이터 바인딩해야합니다.

이것이 문제가되지 않는다면 나는 List<String>을 셀에 데이터 바인딩하는 간단한 예제를 만들었습니다.

private List<String> theList = new List<String>(); 
    public Form1() 
    { 
     InitializeComponent(); 
     theList.Add("is"); 
     theList.Add("this"); 
     theList.Add("working"); 
     theList.Add("yet?"); 
     DataGridViewComboBoxCell dropDown = (DataGridViewComboBoxCell) dgv.Rows[0].Cells[0]; 
     dropDown.DataSource = theList; 

    } 

    private void aButton_Click(object sender, EventArgs e) 
    { 
     theList.Clear(); 
     theList.Add("I"); 
     theList.Add("Knew"); 
     theList.Add("this"); 
     theList.Add("would"); 
     theList.Add("work!!!"); 
    } 

가 어떻게 올바른 값을 설정하는 또 다른 패스를 일을 방지 할 수 있습니다

는 여기 datagridviewcombobox에 목록을 가하고의 예?

(어쩌면) 할 수 없습니다. DataGridview는 한 번에 하나의 결과를로드합니다. 한 셀에 대해 여러 값을 반환하지 않는 한 다른 패스를 수행해야합니다. dgv는 특정 행에 대해 주어진 데이터로 행을 채울 것으로 예상합니다. 시도해 볼 수있는 것은 해당 열이 쿼리에 있음을 인식하지 못하는 것입니다 (쿼리에서 쿼리를 제거하기 만하면 해당 열을 전달하고 값을 할당하지 않을 수 있습니다). 성공하면 다음 행을 만들 때 해당 셀을 자동으로 해당 값으로 만듭니다. 행을 추가하고 셀에 다른 데이터가 없더라도 해당 셀이 즉시 채워지는 경우이 방법이 효과적이라는 것을 알 수 있습니다.


왜 내가 먼저 행을로드해야 만 다음 데이터 소스를 결합 하는가? 이것은 다소 비현실적이며 내 문제를 일으킨다. 요구 사항에서 초기로드 후 어느 시점에 더 많은 데이터가 이로드되도록 요청하면 어떻게됩니까? 바인딩을 다시해야합니까?

데이터 바인딩 대상 개체가 있어야합니다. 열에 대한 데이터 바인딩으로 인해 해당 열의 셀에 데이터 바인딩되지 않습니다. 열 머리글에 데이터 바인딩조차되지 않습니다. 세포에 스스로 데이터 바인딩해야합니다. 일단 데이터 바인딩을하면 원하는만큼 목록을 변경할 수 있으며 목록에 데이터 바인딩 된 셀도 변경됩니다. 일단이 개념을 이해하면 데이터 바인딩은 앞으로 구현하기가 훨씬 쉬워 질 것입니다. 코드를 보면


다시 나는 당신이 데이터 테이블을 채우기 전에 당신이 당신의 열을 만들 좋습니다. 그렇게하면 dgv는 결과를 삽입 할 때 열 생성을 건너 뛰지 않고 해당 열의 데이터 할당을 건너 뜁니다. foreach 루프에서 행을 만들고, 데이터를 할당하고, 데이터를 List<String>에 바인딩하고 datagridview에 행을 추가합니다. 일단 모든 일이 끝나면 마시고, 잘 한 일을 위해 뒤에서 몸을 가볍게 두 드린다. 대신 내가 이전에 말한 일을

편집

이 시도. 그것은 심지어 데이터 바인딩을 포함하지 않습니다. 디자인 타임에 드롭 다운 상자의 문자열 값이 무엇인지 알면 Columns> your_column> Items로 이동하여 문자열을 입력 할 수 있습니다. 그렇지 않으면 괜찮습니다. 당신은 문자열의 목록을 할 때마다 당신과 같이 컬럼의 내부 목록에 추가 할 수 있습니다 :

foo DataGridViewComboBoxColumn = myDGV.columns("YourColumn") 
    foo.Items.Add("blarggg") 

당신이 언제든지 목록을 변경해야하는 경우, 모든 행 말했다 변경하기에 업데이트됩니다.

+0

CheckBoxColumn은 오타였습니다. 질문에서 그 점을 수정했습니다. 로드가 실제로 작동 한 후 바인딩을 이동합니다. 제 수정 된 질문을보고 여분의 질문에 답해 주시면 현상금을드립니다. –

+0

@VladSchnakovszki 답변이 업데이트되었습니다. – Luminous

+0

내 코드는 "내 코드"가 실행되기 전에 디자이너 코드에서 작성됩니다. 그러나 행을 만들 때 각 셀을 데이터 바인딩하는 것이 효과적이며로드 시간이 절반으로 단축되어 어쨌든 얻을 수있는 최선의 방법입니다. 도와 줘서 고마워! –

0

나는 List<string>DataSource으로 작동하지 않을 수 있다는 것을 확실히 말할 수 있습니다. 대신이 아니라도 간단, 클래스의 문자열이 필요 .. :

class StringClass 
{ 
    public string theString { get; set; } 
    public StringClass(string s) { theString = s; } 
    public override string ToString() { return theString;} 
} 

..

DataSource 필요는 속성에서 공급 될 수 있기 때문이다. 당신은 당신의 DataTable에서 이러한 목록을 만들려면이를 시도 할 수 있습니다 :

List<StringClass> industries = DT.AsEnumerable().Select(r=>r[fieldIndex].ToString()) 
      .Distinct().OrderBy(r=>r).Select(r => new StringClass(r)).ToList(); 

는 Obvioulsy 당신은 당신이 그들을 원하지 않는 경우 DistinctOrderBy을두고 필드 인덱스를 변경합니다 ..! MySQL의 테이블로부터 판독

업데이트 여기

(연결)없이 코드 블록이다. 그것은 DataTable DTL에 공급 업체 (lieferanten)의 목록을 읽은 다음 동일한 DB 테이블에서 두 번째 DataTable DTO로 구별되는 위치 (ort)를 읽습니다. 거기에서 위와 같이 목록에 ComboBox의 소스를 가져옵니다.

세 개의 열 (int, string, string)과 두 개의 필요한 템플릿 셀 dct 및 dccb를 만듭니다.

회원을 설정하고 먼저 콤보 박스 셀 DataSource을 설정 한 다음 datagridview를 설정합니다. 로해야

DataGridView를 채우고

모든 콤보 세포 것들

MySqlDataAdapter DA = new MySqlDataAdapter(); 
string sqlSelectAll = "SELECT * from lieferanten"; 
DA.SelectCommand = new MySqlCommand(sqlSelectAll, CO); 

DA.Fill(DTL); 

string sqlSelectOrte = "SELECT DISTINCT ort from lieferanten"; 
DA.SelectCommand = new MySqlCommand(sqlSelectOrte, CO); 

DA.Fill(DTO); 

ortsListe = DTO.AsEnumerable().Select(r => r["ort"].ToString()) 
      .OrderBy(r => r).Select(r => new StringClass(r)).ToList(); 


BindingSource bSource = new BindingSource(); 
bSource.DataSource = DTL; 

dgv_Lief.AutoGenerateColumns = false; 


DataGridViewCell dct = new DataGridViewTextBoxCell(); 

DataGridViewColumn dc0 = new DataGridViewColumn(); 
dc0.ValueType = typeof(int); 
dc0.Name = "lieferanten_key"; 
dc0.DataPropertyName = "lieferanten_key"; 
dc0.CellTemplate = dct; 
dgv_Lief.Columns.Add(dc0); 

DataGridViewColumn dc1 = new DataGridViewColumn(); 
dc1.ValueType = typeof(string); 
dc1.Name = "name"; 
dc1.CellTemplate = dct; 
dc1.DataPropertyName = "firma"; 
dgv_Lief.Columns.Add(dc1); 

DataGridViewComboBoxCell dccb = new DataGridViewComboBoxCell(); 
dccb.DataSource = ortsListe; 
dccb.DisplayMember = "theString"; // using the same field.. 
dccb.ValueMember = "theString"; // .. as I have only one 

DataGridViewColumn dc2 = new DataGridViewColumn(); 
dc2.ValueType = typeof(string); 
dc2.DataPropertyName = "ort"; 
dc2.CellTemplate = dccb; 
dgv_Lief.Columns.Add(dc2); 

dgv_Lief.DataSource = bSource; 

주 순서 .. 적절한 값으로 설정된다. 먼저 DataSource을 포함하여 dccb 템플릿 셀을 설정 한 다음 dgv에 추가 한 다음 dgv의 DataSource을 설정합니다.

위의 StringClass를 사용합니다. 당신이 당신의 열이을로 설정 한 이유는 DGV의 DataSource 내가 행을 추가하고 예상대로 ComboBoxColumn의 값을 사용할 수있는 설정을 생략해도

는 ..

+0

답장을 보내 주셔서 감사합니다. 나는 당신의 제안을 시도했으나 효과가 없었습니다. 내 편집 된 질문을 참조하십시오. –

+0

업데이트 된 답변보기 – TaW

0

Windows Forms 디자이너를 사용하여 실제로 코드 행을 작성하지 않고도이 모든 작업을 수행 할 수 있습니다.

데이터 메뉴에서 새 데이터 원본을 추가하십시오.

데이터베이스 선택하고

당신은 당신의 데이터 세트에서 (비즈니스 및 업계 테이블 모두)를 포함 할 테이블을 선택하고 연결 문자열 정보를 입력 다음

선택 데이터 집합을 클릭 한 다음

을 클릭

마법사 완료

데이터 원본 창에서 비즈니스 테이블 o 네 양식에. 이렇게하면 모든 열이있는 데이터 격자보기가 생성되고 바인딩 원본과 테이블 어댑터를 추가하여 채 웁니다. 하여 데이터 그리드 뷰의 오른쪽 위에있는 작은 화살표를 선택 열 편집

클릭, 업계 열을 선택하고 열기가 데이터 소스가 드롭 다운 DataGridViewComboBox 열

에 열 유형을 변경 새로 생성 된 데이터 세트에서 industries 테이블을 선택하십시오.

표시 멤버를 name 열로, 값 멤버를 기본 키 열로 설정하십시오.

그런 다음 양식 디자이너가 생성 한 코드를보고 어떻게 합치는지 확인할 수 있습니다. 가장 예쁜 코드는 아니지만 코드는 작성하지 않아도됩니다.

재미있는 부분은 데이터 소스, 바인딩 원본 및 테이블 어댑터를 모두 포함하는 것입니다.

데이터 세트에 대해 약간의 추가 작업 만 수행하면 데이터베이스에 다시 저장할 수도 있습니다.

을 Heres이 나의 빠른 시도의 결과 :

using System; 
using System.Windows.Forms; 

namespace WindowsFormsBindingDemo 
{ 
public partial class BusinessesForm : Form 
{ 
    /// <summary> 
    /// Required designer variable. 
    /// </summary> 
    private System.ComponentModel.IContainer components = null; 

    private System.Windows.Forms.DataGridView businessesDataGridView; 
    private BusinessesDataSet businessesDataSet; 
    private System.Windows.Forms.BindingSource businessesBindingSource; 
    private BusinessesDataSetTableAdapters.BusinessesTableAdapter businessesTableAdapter; 
    private BusinessesDataSetTableAdapters.TableAdapterManager tableAdapterManager; 
    private BusinessesDataSetTableAdapters.IndustriesTableAdapter industriesTableAdapter; 
    private System.Windows.Forms.BindingSource industriesBindingSource; 
    private System.Windows.Forms.DataGridViewTextBoxColumn iDDataGridViewTextBoxColumn; 
    private System.Windows.Forms.DataGridViewComboBoxColumn industryIDDataGridViewTextBoxColumn; 
    private System.Windows.Forms.DataGridViewTextBoxColumn businessNameDataGridViewTextBoxColumn; 

    public BusinessesForm() 
    { 
     this.components = new System.ComponentModel.Container(); 
     this.businessesDataGridView = new System.Windows.Forms.DataGridView(); 
     this.businessesDataSet = new WindowsFormsBindingDemo.BusinessesDataSet(); 
     this.businessesBindingSource = new System.Windows.Forms.BindingSource(this.components); 
     this.businessesTableAdapter = new WindowsFormsBindingDemo.BusinessesDataSetTableAdapters.BusinessesTableAdapter(); 
     this.tableAdapterManager = new WindowsFormsBindingDemo.BusinessesDataSetTableAdapters.TableAdapterManager(); 
     this.industriesBindingSource = new System.Windows.Forms.BindingSource(this.components); 
     this.industriesTableAdapter = new WindowsFormsBindingDemo.BusinessesDataSetTableAdapters.IndustriesTableAdapter(); 
     this.iDDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
     this.industryIDDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewComboBoxColumn(); 
     this.businessNameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
     ((System.ComponentModel.ISupportInitialize)(this.businessesDataGridView)).BeginInit(); 
     ((System.ComponentModel.ISupportInitialize)(this.businessesDataSet)).BeginInit(); 
     ((System.ComponentModel.ISupportInitialize)(this.businessesBindingSource)).BeginInit(); 
     ((System.ComponentModel.ISupportInitialize)(this.industriesBindingSource)).BeginInit(); 
     this.SuspendLayout(); 
     // 
     // businessesDataGridView 
     // 
     this.businessesDataGridView.AutoGenerateColumns = false; 
     this.businessesDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; 
     this.businessesDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { 
     this.iDDataGridViewTextBoxColumn, 
     this.industryIDDataGridViewTextBoxColumn, 
     this.businessNameDataGridViewTextBoxColumn}); 
     this.businessesDataGridView.DataSource = this.businessesBindingSource; 
     this.businessesDataGridView.Dock = System.Windows.Forms.DockStyle.Fill; 
     this.businessesDataGridView.Location = new System.Drawing.Point(0, 0); 
     this.businessesDataGridView.Name = "businessesDataGridView"; 
     this.businessesDataGridView.RowTemplate.Height = 24; 
     this.businessesDataGridView.Size = new System.Drawing.Size(554, 374); 
     this.businessesDataGridView.TabIndex = 0; 
     // 
     // businessesDataSet 
     // 
     this.businessesDataSet.DataSetName = "BusinessesDataSet"; 
     this.businessesDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema; 
     // 
     // businessesBindingSource 
     // 
     this.businessesBindingSource.DataMember = "Businesses"; 
     this.businessesBindingSource.DataSource = this.businessesDataSet; 
     // 
     // businessesTableAdapter 
     // 
     this.businessesTableAdapter.ClearBeforeFill = true; 
     // 
     // tableAdapterManager 
     // 
     this.tableAdapterManager.BackupDataSetBeforeUpdate = false; 
     this.tableAdapterManager.BusinessesTableAdapter = this.businessesTableAdapter; 
     this.tableAdapterManager.IndustriesTableAdapter = this.industriesTableAdapter; 
     this.tableAdapterManager.UpdateOrder = WindowsFormsBindingDemo.BusinessesDataSetTableAdapters.TableAdapterManager.UpdateOrderOption.InsertUpdateDelete; 
     // 
     // industriesBindingSource 
     // 
     this.industriesBindingSource.DataMember = "Industries"; 
     this.industriesBindingSource.DataSource = this.businessesDataSet; 
     // 
     // industriesTableAdapter 
     // 
     this.industriesTableAdapter.ClearBeforeFill = true; 
     // 
     // iDDataGridViewTextBoxColumn 
     // 
     this.iDDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; 
     this.iDDataGridViewTextBoxColumn.DataPropertyName = "ID"; 
     this.iDDataGridViewTextBoxColumn.HeaderText = "ID"; 
     this.iDDataGridViewTextBoxColumn.Name = "iDDataGridViewTextBoxColumn"; 
     this.iDDataGridViewTextBoxColumn.ReadOnly = true; 
     // 
     // industryIDDataGridViewTextBoxColumn 
     // 
     this.industryIDDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; 
     this.industryIDDataGridViewTextBoxColumn.DataPropertyName = "IndustryID"; 
     this.industryIDDataGridViewTextBoxColumn.DataSource = this.industriesBindingSource; 
     this.industryIDDataGridViewTextBoxColumn.DisplayMember = "IndustryName"; 
     this.industryIDDataGridViewTextBoxColumn.FillWeight = 300F; 
     this.industryIDDataGridViewTextBoxColumn.HeaderText = "IndustryID"; 
     this.industryIDDataGridViewTextBoxColumn.Name = "industryIDDataGridViewTextBoxColumn"; 
     this.industryIDDataGridViewTextBoxColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True; 
     this.industryIDDataGridViewTextBoxColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; 
     this.industryIDDataGridViewTextBoxColumn.ValueMember = "ID"; 
     // 
     // businessNameDataGridViewTextBoxColumn 
     // 
     this.businessNameDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; 
     this.businessNameDataGridViewTextBoxColumn.DataPropertyName = "BusinessName"; 
     this.businessNameDataGridViewTextBoxColumn.FillWeight = 300F; 
     this.businessNameDataGridViewTextBoxColumn.HeaderText = "BusinessName"; 
     this.businessNameDataGridViewTextBoxColumn.Name = "businessNameDataGridViewTextBoxColumn"; 
     // 
     // BusinessesForm 
     // 
     this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); 
     this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 
     this.ClientSize = new System.Drawing.Size(554, 374); 
     this.Controls.Add(this.businessesDataGridView); 
     this.Name = "BusinessesForm"; 
     this.Text = "Businesses"; 
     this.Load += new System.EventHandler(this.BusinessesForm_Load); 
     ((System.ComponentModel.ISupportInitialize)(this.businessesDataGridView)).EndInit(); 
     ((System.ComponentModel.ISupportInitialize)(this.businessesDataSet)).EndInit(); 
     ((System.ComponentModel.ISupportInitialize)(this.businessesBindingSource)).EndInit(); 
     ((System.ComponentModel.ISupportInitialize)(this.industriesBindingSource)).EndInit(); 
     this.ResumeLayout(false); 
    } 


    private void BusinessesForm_Load(object sender, EventArgs e) 
    { 
     // TODO: This line of code loads data into the 'businessesDataSet.Industries' table. You can move, or remove it, as needed. 
     this.industriesTableAdapter.Fill(this.businessesDataSet.Industries); 
     // TODO: This line of code loads data into the 'businessesDataSet.Businesses' table. You can move, or remove it, as needed. 
     this.businessesTableAdapter.Fill(this.businessesDataSet.Businesses); 
    } 



    /// <summary> 
    /// Clean up any resources being used. 
    /// </summary> 
    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 
    protected override void Dispose(bool disposing) 
    { 
     if (disposing && (components != null)) 
     { 
      components.Dispose(); 
     } 
     base.Dispose(disposing); 
    } 

} 

}

+0

슬프게도 데이터베이스를 MySQL로 지원할 수 없어 디자이너를 통해 지원되지 않습니다. –