Listview Sub Item Edit

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • uday1302
    New Member
    • Mar 2008
    • 18

    Listview Sub Item Edit

    Hi,
    Can anyone trace out where is the error

    Code:
    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();
            }
    Last edited by pbmods; Jan 28 '09, 04:49 AM. Reason: Added CODE tags.
  • IanWright
    New Member
    • Jan 2008
    • 179

    #2
    What is the error? If it's somewhere in there try debugging it, otherwise you'll need to give more information.

    Comment

    • Curtis Rutland
      Recognized Expert Specialist
      • Apr 2008
      • 3264

      #3
      I'm afraid we can't...we are here to help you help yourself, not to do your job for you.

      Debug it, find the exact line with the error, and post the line and error message.

      If it is a logic error, rather than a syntax error, describe what it is supposed to do versus what it is doing.

      MODERATOR

      Comment

      • uday1302
        New Member
        • Mar 2008
        • 18

        #4
        Hi,
        Here I am trying to edit value in lstListView.Sel ectedItems[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.
        Is that clear..

        Comment

        Working...