ListView 셀 클릭 추가 컨트롤
6023 단어 ListView
만약 한 줄에 combobox가 하나밖에 없다면.
//
private ComboBox[] cmds = null;
//initview dao
List<Indicator> plist = idao.queryIndicators();
// new cmds
cmds=new ComboBox[plist.Count];
// view SelectedIndexChanged
if (this.listView1.SelectedItems.Count > 0)
{
//
ListViewItem item = this.listView1.SelectedItems[0];
//
int index=this.listView1.SelectedIndices[0];
cmds[index] = new ComboBox();
for (int i = 1; i <= 50; i++){
cmds[index].Items.Add(i + "");
cmds[index].SelectedItem = "20";
cmds[index].Bounds = item.SubItems[3].Bounds;
listView1.Controls.Add(cmds[index]);
cmds[index].Show();
}
} 한 줄에 combobox가 여러 개 있다면?이것은 한 줄과 한 줄의 차이점은 한 줄에 두 줄이 선택된 줄이 어느 줄인지 확인해야 할 뿐만 아니라, 어느 열도 확인해야 한다는 것이다.
비록 이 점만 모자라지만, 실현은 확실히 완전히 다르다.
private void indicatorView_MouseMove(object sender, MouseEventArgs e)//获取鼠标位置
{
mousePos.X = e.X;
mousePos.Y = e.Y;
}
private void indicatorView_Click(object sender, EventArgs e) { ListViewItem item = indicatorView.GetItemAt(mousePos.X, mousePos.Y);// item Rectangle rect = item.GetBounds(ItemBoundsPortion.Entire); int StartX = rect.Left; int ColumnIndex = 0; int pos = GetScrollPos(this.indicatorView.Handle.ToInt32(), 0); foreach (ColumnHeader Column in indicatorView.Columns)// { if (mousePos.X + pos >= StartX + Column.Width) { StartX += Column.Width; ColumnIndex += 1; } } if (ColumnIndex == this.indicatorView.Columns.Count - 1)// { int index = this.indicatorView.SelectedIndices[0]; indicatorViewComboBox[index] = new ComboBox(); for (int i = 0; i <= 50; i+=10) indicatorViewComboBox[index].Items.Add(i + ""); indicatorViewComboBox[index].SelectedItem = "20"; indicatorViewComboBox[index].Bounds = item.SubItems[ColumnIndex].Bounds; indicatorView.Controls.Add(indicatorViewComboBox[index]); indicatorViewComboBox[index].Show(); } else if (ColumnIndex == this.indicatorView.Columns.Count - 2) { // } }
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Flutter의 ListTile에서 높이를 지정하면 레이아웃이 무너지는 문제현재 업무로 1개월 반 정도 Flutter를 사용하고 있습니다. 아주 좋은 팀으로, 최근에는 Flutter 자체에도 열중해 왔습니다. title, subtitle, leading, trailing 등을 설정하는 것만...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.