473,323 Members | 1,547 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Listview Sub Item Edit

Hi,
Can anyone trace out where is the error

Expand|Select|Wrap|Line Numbers
  1. lstListView.DoubleClick += new EventHandler(this.lstEditDoubleClick);
  2. txtSubItem.KeyPress += new KeyPressEventHandler(this.txtEditOver);
  3. lstListView.MouseDown += new MouseEventHandler(this.lstEditMouseDown);
  4. public void lstEditMouseDown(object sender, MouseEventArgs e)
  5.         {
  6.             ListViewItem item = lstListView.GetItemAt(e.X, e.Y);
  7.             X = e.X;
  8.             Y = e.Y;
  9.         }
  10. private void lstEditDoubleClick(object sender, EventArgs e)
  11.         {
  12.             int nStart = X;
  13.             int spos = 0;
  14.             int epos = lstListView.Columns[0].Width;
  15.             for (int i = 0; i < lstListView.Columns.Count; i++)
  16.             {
  17.                 spos = epos + X;
  18.                 epos += lstListView.Columns[3].Width;
  19.             }
  20.             subItemText = lstListView.SelectedItems[0].SubItems[3].Text;
  21.             Rectangle r = new Rectangle(spos, lstListView.SelectedItems[0].SubItems[3].Bounds.Y, epos, lstListView.SelectedItems[0].SubItems[3].Bounds.Bottom);
  22.             txtSubItem.Size = new System.Drawing.Size(epos - spos, lstListView.SelectedItems[0].SubItems[3].Bounds.Bottom - lstListView.SelectedItems[0].SubItems[3].Bounds.Top);
  23.             txtSubItem.Location = new System.Drawing.Point(spos, lstListView.SelectedItems[0].SubItems[3].Bounds.Y);
  24.             txtSubItem.Show();
  25.             txtSubItem.Text = subItemText;
  26.         }
  27.         private void txtEditOver(object sender, KeyPressEventArgs e)
  28.         {
  29.             if (e.KeyChar == 13)
  30.             {
  31.                 lstListView.SelectedItems[0].SubItems[3].Text = txtSubItem.Text;
  32.                 txtSubItem.Hide();
  33.             }
  34.             if (e.KeyChar == 27)
  35.                 txtSubItem.Hide();
  36.         }
Jan 27 '09 #1
3 4248
IanWright
179 100+
What is the error? If it's somewhere in there try debugging it, otherwise you'll need to give more information.
Jan 28 '09 #2
Curtis Rutland
3,256 Expert 2GB
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
Jan 28 '09 #3
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.
Is that clear..
Jan 28 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: John Lauwers | last post by:
I know you can edit the first column of the listview control, is there a way to edit the second and/or the other columns? greets John
1
by: J_Max | last post by:
Hello, This might be a really easy question, but... I am developing a simple Smart Device application that uses a listview. I have a function that adds a item to the listview - code is below. I...
3
by: MikeY | last post by:
Hopefully someone can help me on this. I am using C#, making Windows forms. I have created a listView with checkbox's. I have enabled the checkboxes under the properties, and all the data,...
2
by: David Anderson | last post by:
I'm working on a Windows app that has a ListView containing a bunch of items. When the user clicks on an item, the app displays the item'd details. The user then has the opportunity to edit these...
1
by: Pep | last post by:
Hi, I'm using a ListView control in an app I'm developing... When a user clicks the New button in my form I add a new ListViewItem and call the BeginEdit() function on this item. My problem...
10
by: HABJAN ®iga | last post by:
Ok, the trouble: On form: Mask (lots of textboxes & ...) Listview 1 as Listview with some items booEdit as boolean=False intEditIndex as integer Scenario:
5
by: Matt Michael | last post by:
Hi, I'm having a problem working with a listview in an application I'm writing. Currently, whenever the selectedindex changed event fires, it loads up a htmledit control, and other labels on the...
6
by: Stanley | last post by:
Hi all! I have problem trying to edit the item in listview. When I set LabelEdit to True, I can only edit the first column's item. How about editing another column's item?? Thanks in advance! ...
1
by: samoore33 | last post by:
I found this code on MSDN, and it works great. It creates a ListView dynamically and add items to it and all. It is great. I have changed a few of the column names to suit me. Dim listView1 As...
0
by: DJOuk | last post by:
Posted this on Asp.Net, seems to be a hard problem, I still can't work it out I have a edit button, this works fine, until I add the code that prevents the edit button from being seen by users who...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.