2012-02-13 2 views
-1

콤보 상자 드롭 다운에서 gridview 표시하려면 C# 방법이 있습니까? 사용자가 콤보 박스를 클릭 할 때 드롭 다운 대신에 콤보 박스의 하단에 여러 개의 행과 열이있는 gridview를 표시하려고합니다.콤보 상자 드롭 다운의 gridview 표시. C#

+0

u WPF 컨트롤 확인 – kbvishnu

+0

WinForms를 사용하고 있습니까? WPF? 다른 것? –

답변

0

이 작업을 수행하는 간단한 방법은 없습니다. 드롭 다운을 원하는대로 작동하도록 변경할 수 없습니다. 자체 컨트롤을 만들어야합니다.

  • 텍스트 영역 (일반적인 콤보 상자 같은) 버튼으로 구성된 사용자 컨트롤을 만듭니다 : 여기

    은 당신이해야 할 단계입니다. 이러한 메서드를 사용하여 ComboBox와 똑같이 컨트롤을 그릴 수 있습니다.

    ComboBoxRenderer.DrawTextBox (Graphics g, Rectangle bounds, ComboBoxState state); ComboBoxRenderer.DrawDropDownButton (그래픽 g, Rectangle 경계, ComboBoxState 상태); 사용 버튼을 클릭 한 후

그런 다음 당신은 당신의 ListView를 포함 드롭 다운을 표시해야합니다. 당신은 일부 드롭 다운이 구성 요소를 사용할 수 있습니다

나는 몇 년 전에 그런 일을 한

http://www.codeproject.com/Articles/17502/Simple-Popup-Control

. CodeProject 기사로 변환 할 시간이 필요합니다!

0
SqlConnection con = new SqlConnection("server=(local);DataBase=RIMS;User Id=sa;Password=Rootdb"); 
SqlCommand com = new SqlCommand("Select * from Master_City", con); 
SqlDataAdapter da = new SqlDataAdapter(com); 
DataSet ds = new DataSet(); 
da.Fill(ds, "city"); 
dataGridView1.DataSource = ds; 
dataGridView1.DataMember = "city"; 

DataGridViewComboBoxColumn col = new DataGridViewComboBoxColumn(); 
col.HeaderText = "Name"; 
col.Name = "Name"; 
col.DataSource = ds.Tables[0]; 
col.DisplayMember = ds.Tables[0].Columns[1].ToString(); 
dataGridView1.Columns.Add(col); 
관련 문제