Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Listview Sub item Edit

Listview Sub item Edit

Scheduled Pinned Locked Moved C#
graphicsdebugginghelp
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    Udayaraju
    wrote on last edited by
    #1

    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(); }

    W D 2 Replies Last reply
    0
    • U Udayaraju

      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(); }

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #2

      It would greatly help if you tell what kind of error you have? Exception (what exception, where), something not working the way you want etc.

      The need to optimize rises from a bad design.My articles[^]

      1 Reply Last reply
      0
      • U Udayaraju

        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(); }

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        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

        U 1 Reply Last reply
        0
        • D Dave Kreskowiak

          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

          U Offline
          U Offline
          Udayaraju
          wrote on last edited by
          #4

          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. The position of textbox is not displayed in required column.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups