Listview Sub item Edit
-
Hi, Can anyone trace out where is the error lstListView.DoubleClick += new EventHandler(this.lstEditDoubleClick); txtSubItem.KeyPress += new KeyPressEventHandler(this.txtEditOver); lstListView.MouseDown += new MouseEventHandler(this.lstEditMouseDown); public void lstEditMouseDown(object sender, MouseEventArgs e) { ListViewItem item = lstListView.GetItemAt(e.X, e.Y); X = e.X; Y = e.Y; } private void lstEditDoubleClick(object sender, EventArgs e) { int nStart = X; int spos = 0; int epos = lstListView.Columns[0].Width; for (int i = 0; i < lstListView.Columns.Count; i++) { spos = epos + X; epos += lstListView.Columns[3].Width; } subItemText = lstListView.SelectedItems[0].SubItems[3].Text; Rectangle r = new Rectangle(spos, lstListView.SelectedItems[0].SubItems[3].Bounds.Y, epos, lstListView.SelectedItems[0].SubItems[3].Bounds.Bottom); txtSubItem.Size = new System.Drawing.Size(epos - spos, lstListView.SelectedItems[0].SubItems[3].Bounds.Bottom - lstListView.SelectedItems[0].SubItems[3].Bounds.Top); txtSubItem.Location = new System.Drawing.Point(spos, lstListView.SelectedItems[0].SubItems[3].Bounds.Y); txtSubItem.Show(); txtSubItem.Text = subItemText; } private void txtEditOver(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { lstListView.SelectedItems[0].SubItems[3].Text = txtSubItem.Text; txtSubItem.Hide(); } if (e.KeyChar == 27) txtSubItem.Hide(); }
-
Hi, Can anyone trace out where is the error lstListView.DoubleClick += new EventHandler(this.lstEditDoubleClick); txtSubItem.KeyPress += new KeyPressEventHandler(this.txtEditOver); lstListView.MouseDown += new MouseEventHandler(this.lstEditMouseDown); public void lstEditMouseDown(object sender, MouseEventArgs e) { ListViewItem item = lstListView.GetItemAt(e.X, e.Y); X = e.X; Y = e.Y; } private void lstEditDoubleClick(object sender, EventArgs e) { int nStart = X; int spos = 0; int epos = lstListView.Columns[0].Width; for (int i = 0; i < lstListView.Columns.Count; i++) { spos = epos + X; epos += lstListView.Columns[3].Width; } subItemText = lstListView.SelectedItems[0].SubItems[3].Text; Rectangle r = new Rectangle(spos, lstListView.SelectedItems[0].SubItems[3].Bounds.Y, epos, lstListView.SelectedItems[0].SubItems[3].Bounds.Bottom); txtSubItem.Size = new System.Drawing.Size(epos - spos, lstListView.SelectedItems[0].SubItems[3].Bounds.Bottom - lstListView.SelectedItems[0].SubItems[3].Bounds.Top); txtSubItem.Location = new System.Drawing.Point(spos, lstListView.SelectedItems[0].SubItems[3].Bounds.Y); txtSubItem.Show(); txtSubItem.Text = subItemText; } private void txtEditOver(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { lstListView.SelectedItems[0].SubItems[3].Text = txtSubItem.Text; txtSubItem.Hide(); } if (e.KeyChar == 27) txtSubItem.Hide(); }
-
Hi, Can anyone trace out where is the error lstListView.DoubleClick += new EventHandler(this.lstEditDoubleClick); txtSubItem.KeyPress += new KeyPressEventHandler(this.txtEditOver); lstListView.MouseDown += new MouseEventHandler(this.lstEditMouseDown); public void lstEditMouseDown(object sender, MouseEventArgs e) { ListViewItem item = lstListView.GetItemAt(e.X, e.Y); X = e.X; Y = e.Y; } private void lstEditDoubleClick(object sender, EventArgs e) { int nStart = X; int spos = 0; int epos = lstListView.Columns[0].Width; for (int i = 0; i < lstListView.Columns.Count; i++) { spos = epos + X; epos += lstListView.Columns[3].Width; } subItemText = lstListView.SelectedItems[0].SubItems[3].Text; Rectangle r = new Rectangle(spos, lstListView.SelectedItems[0].SubItems[3].Bounds.Y, epos, lstListView.SelectedItems[0].SubItems[3].Bounds.Bottom); txtSubItem.Size = new System.Drawing.Size(epos - spos, lstListView.SelectedItems[0].SubItems[3].Bounds.Bottom - lstListView.SelectedItems[0].SubItems[3].Bounds.Top); txtSubItem.Location = new System.Drawing.Point(spos, lstListView.SelectedItems[0].SubItems[3].Bounds.Y); txtSubItem.Show(); txtSubItem.Text = subItemText; } private void txtEditOver(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { lstListView.SelectedItems[0].SubItems[3].Text = txtSubItem.Text; txtSubItem.Hide(); } if (e.KeyChar == 27) txtSubItem.Hide(); }
Udayaraju wrote:
Can anyone trace out where is the error
Not without you telling us what the error is, which line it occurs, what the results are and what the expected results are...
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
Udayaraju wrote:
Can anyone trace out where is the error
Not without you telling us what the error is, which line it occurs, what the results are and what the expected results are...
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008Hi, Here I am trying to edit value in lstListView.SelectedItems[0].SubItems[3] column. The textbox I have placed is not displayed at that coulmn position. I have done with all the possibilites but unable to place the textbox in required Location. The position of textbox is not displayed in required column.