Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Post
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
1
Reply
Change text to edit in BeforeLabelEdit( ) event?
Chris W
Mar 16 2006 2:55 PM
3.3k
Reply
Does anyone know if it is possible in a ListView BeforeLabelEdit event to change the text that user is going to edit, just before the edit?
Here's my code. None of the items below (remmed out) work to change the text the user is going to edit. Any ideas are greatly appreciated!!
private
void
listView1_BeforeLabelEdit(
object
sender, System.Windows.Forms.LabelEditEventArgs e){
// Remove "(default)" from the template name
string
name =
this
.listView1.SelectedItems[0].Text;
if
(name.IndexOf(" (default)") >= 0)
{
// Remove the word
name = name.Substring(0, name.Length - 10);
// NONE OF THESE THINGS WORK TO FORCE USER TO MODIFY THE NEW TEXT!
//e.Label = name; // READ-ONLY!
//this.listView1.Items[e.Item].Text = name; // REMOVES (default) AFTER EDIT!
//this
.listView1.SelectedItems[0].Text = name;
// REMOVES (default) AFTER EDIT!
// Cancel event and refire it?
//e.CancelEdit = true; //DOES NOT WORK!
//listView1_BeforeLabelEdit(sender, e); //DOES NOT WORK!
}
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
xml keys and value display on cosole
Single quotes conversion in c# or Javascript?