Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / June 2007

Tip: Looking for answers? Try searching our database.

Cheking of entered symbols in current Treenode

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dmitriy Sonechko - 06 Jun 2007 12:05 GMT
Hi there!

In my Treeview Control I am trying to edit some of the nodes.
For this purpose I am using mytree.beginedit(), so after this the node
is ready for editing. But I need to avoid of entering some symbols
during editing.
So I need smth like KeyPress Event for current TreeNode to be fired to
implement some symbol cheking.

Could you advice me smth?

Treeview property LabelEdit is set to True.

Thanks in advance!

Dmitriy.
CSharpner - 06 Jun 2007 15:37 GMT
What is "smth"?  I keep wanting to read it as "Smith", but that can't
be it.

> Hi there!
>
[quoted text clipped - 14 lines]
>
> *** Sent via Developersdexhttp://www.developersdex.com***
Dmitriy Sonechko - 07 Jun 2007 12:48 GMT
Hi CSharpner,

smth means something

Thanks,

Dmitriy
CSharpner - 08 Jun 2007 18:20 GMT
The TreeNode itself has no events, so you need to evaluate the
validity after they submit the name.  You can do that in the
AfterLabelEdit event of the TreeView.  Otherwise, you'll need to
insert yourself into the Windows Event loop.  The form's KeyPreview
property won't even cause keypresses to fire the form's KeyPress
event.

Here's code that I tested as working using the AfterLabelEdit.

       // Put your valid characters in this string...
       private string ValidChars =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345679";

       private void treeView1_AfterLabelEdit(object sender,
NodeLabelEditEventArgs e)
       {
           string InvalidChars = "";
           for(int x = 0; x < e.Label.Length; x++)
               if (!ValidChars.Contains("" + e.Label[x]))
                   InvalidChars+= e.Label[x];

           if (InvalidChars.Length > 0)
           {
               e.CancelEdit = true;
               MessageBox.Show("The following characters are invalid
\n" + InvalidChars);
           }
       }

> HiCSharpner,
>
[quoted text clipped - 5 lines]
>
> *** Sent via Developersdexhttp://www.developersdex.com***

> Hi there!
>
[quoted text clipped - 14 lines]
>
> *** Sent via Developersdexhttp://www.developersdex.com***

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.