반응형
public class ListViewWithComboBox : ListView
{
//Field
ComboBox _comboBox;
ListViewItem.ListViewSubItem item;
//properties
public ComboBox ComBoBox
{
get { return _comboBox; }
set { _comboBox = value; }
}
//Constructor
public ListViewWithComboBox()
: base()
{
ComBoBox = new ComboBox();
//콤보박스에 값을 셋팅해준다
ComBoBox.LostFocus += new EventHandler(ComBoBox_LostFocus);
ComBoBox.SelectedValueChanged += new EventHandler(ComBoBox_SelectedValueChanged);
}
//public Method
public void showComboBox()
{
item = this.SelectedItems[0].SubItems[1];
_comboBox.Location = item.Bounds.Location;
_comboBox.Size = item.Bounds.Size;
_comboBox.SelectedValueChanged -= new EventHandler(ComBoBox_SelectedValueChanged);
_comboBox.Text = item.Text;
_comboBox.SelectedValueChanged += new EventHandler(ComBoBox_SelectedValueChanged);
this.Controls.Add(_comboBox);
_comboBox.Focus();
}
//Event
void ComBoBox_SelectedValueChanged(object sender, EventArgs e)
{
ComboBox combobox = sender as ComboBox;
//ListView의 Item에 값을 셋팅한다.
item.Text = combobox.SelectedItem.ToString();
this.Controls.Remove(ComBoBox);
}
void ComBoBox_LostFocus(object sender, EventArgs e)
{
this.Controls.Remove(_comboBox);
}
}
'Programing > C# ' 카테고리의 다른 글
ColorComboBox 만들기 (0) | 2012.06.21 |
---|---|
Color이름으로 Color객체 얻어오기 (0) | 2012.06.21 |
Convert Base64 To Image (0) | 2012.06.07 |
WindowForm에서 File DragAndDrop (0) | 2012.05.16 |
Enum값을 PropertyGrid에 원하는 형태로 바꿔서 출력하는 방법 EnumConverter (0) | 2012.05.16 |