-
January 27th, 2009, 02:57 PM
#1
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();
}
-
January 27th, 2009, 03:58 PM
#2
Re: Listview Sub Item Edit
We're not debuggers. Give us a real question to answer, tell us what you have tried, what the problem is. Also, please use code tags.
-
January 28th, 2009, 10:59 AM
#3
Re: Listview Sub Item Edit
Hi,
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.
-
January 29th, 2009, 03:31 AM
#4
Re: Listview Sub Item Edit
Hi, you need to first determine the top and left edge values for the container of your listview (this may be a form if it is, then ignore these values). Next you determine the left and top edge of the listview. Now you get the listview items .position property and use the listview.item.columns[?].width property to determine how far over to go. Based on that you can calculate where to position your text box.
Last edited by Traps; January 29th, 2009 at 03:34 AM.
-
January 29th, 2009, 03:34 AM
#5
Re: Listview Sub Item Edit
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|