2013-09-10 1 views
1

datagridviewcombobox 열 gridviewcomboboxcolumns에 어떤 아이디어 PLX을이 작업을 수행하는 방법에

// 폼로드 이벤트

IndexChange 이벤트를 선택한
string query="select article_name from article"; 
SqlCommmand cmd = new SqlCommand(query,con); 
SqlDataAdapter da= new SqlDataAdapter(cmd); 
DataTable dt=new DataTable(); 
da.Fill(dt); 
combobox1.items.clear(); 
for(int i=0;i<dt.rows.count;i++) 
{ 
combobox1.items.add(dt.rows[i].cells[0].toString()); 
} 

\ 콤보 상자

string query1="select description from article where article_name='"+combobox1.selectedItem.ToString()+"'"; 
SqlCommmand cmd1 = new SqlCommand(query1,con); 
SqlDataAdapter da1= new SqlDataAdapter(cmd); 
DataTable dt1=new DataTable(); 
da1.Fill(dt1); 
combobox2.items.clear(); 
for(int i=0;i<dt1.rows.count;i++) 
{ 
combobox2.items.add(dt1.rows[i].cells[0].toString()); 
} 
,451,515,

이제 \이 2 combox을 가정하는 것은 gridviewCombobox 열이 어떻게

Project in Windows Form in C# 
+0

같은 문제의 형제에 가고 있었고, 난이 필요 – naeemshah1

답변

0

의 도움이 있기 때문에 몇 달 후이 answer을 게시 있어요 whoose thoose에 대한 gridviewcombobox 컬럼에이 일을하는 것입니다 직면 해있는 문제 DataGridviewComboboxcell 나는 나의 자신의 기술을했다 나의 첫번째/메인 칼럼을 먼저 채운다

그 후

은 내가 Cell End Edit

if (dataGridView1.CurrentCell == dataGridView1.CurrentRow.Cells["article_name"]) 
       { 
        string CategoryValue = ""; 
        //string CategoryValue1 = ""; 

        if (dataGridView1.CurrentCell.Value != null) 
        { 
         CategoryValue = dataGridView1.CurrentCell.Value.ToString(); 
         //CategoryValue1 = dataGridView1.CurrentCell.Value.ToString(); 
        } 
        //SqlConnection objCon = new SqlConnection(@"Data Source=.\SqlExpress;Initial Catalog=dbTest3;Integrated Security=True"); 
        string query = "select article_name,composition from Setup_article_custominvoice where article_name='" + CategoryValue + "'"; 
        SqlCommand objCmd = new SqlCommand(query, con); 

        SqlDataAdapter objDA = new SqlDataAdapter(objCmd); 

        objDA.SelectCommand.CommandText = objCmd.CommandText.ToString(); 
        DataTable dt = new DataTable(); 

        objDA.Fill(dt); 

        DataGridViewComboBoxCell t = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[2] as DataGridViewComboBoxCell; 
        t.DataSource = dt; 
        t.DisplayMember = "composition"; 

       } 
관련 문제