Click here to Skip to main content
15,885,216 members
Home / Discussions / C#
   

C#

 
GeneralRe: Selected text in TreeNodes Pin
Guinness4Strength30-Jan-04 3:56
Guinness4Strength30-Jan-04 3:56 
GeneralRe: Selected text in TreeNodes Pin
Anonymous30-Jan-04 4:00
Anonymous30-Jan-04 4:00 
GeneralRe: Selected text in TreeNodes Pin
Guinness4Strength30-Jan-04 4:12
Guinness4Strength30-Jan-04 4:12 
GeneralRe: Selected text in TreeNodes Pin
Guinness4Strength30-Jan-04 4:40
Guinness4Strength30-Jan-04 4:40 
GeneralRe: Selected text in TreeNodes Pin
Anonymous31-Jan-04 2:37
Anonymous31-Jan-04 2:37 
GeneralRe: Selected text in TreeNodes Pin
Heath Stewart30-Jan-04 5:02
protectorHeath Stewart30-Jan-04 5:02 
GeneralRe: Selected text in TreeNodes Pin
Guinness4Strength30-Jan-04 4:42
Guinness4Strength30-Jan-04 4:42 
GeneralRe: Selected text in TreeNodes Pin
Heath Stewart30-Jan-04 5:14
protectorHeath Stewart30-Jan-04 5:14 
This should work, but you can also get the edit control (a TextBox in .NET) that the Tree-View common control uses during label edits by handling the TVN_BEGINLABELEDIT notification message in TreeView.WndProc and then call a P/Invoked SendMessage with the TVM_GETEDITCONTROL:
public class MyTreeView : TreeView
{
  private TextBox editBox;
  protected override void WndProc(ref Message m)
  {
    if (m.Msg == TVN_BEGINLABELEDIT)
    {
      IntPtr hWnd = SendMessage(this.Handle, TVN_BEGINLABELEDIT, 0, 0);
      if (hWnd != IntPtr.Zero)
        this.editBox = (TextBox)Control.FromHandle(hWnd);
    }
    else if (m.Msg == TVN_ENDLABELEDIT)
      this.editBox = null;
  }
  [DllImport("user32.dll")]
  private static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam,
    int lParam);
  private const TVN_BEGINLABELEDIT = 0x10c5;
  private const TVN_ENDLABELEDIT = 0x10c4;
  private const TVM_GETEDITCONTROL = 0x110f;
}
This way, you're not overlapping controls which can lead to problems, and you'll have to handle all the getting and setting of text.

 

-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
GeneralRe: Selected text in TreeNodes Pin
Guinness4Strength30-Jan-04 5:18
Guinness4Strength30-Jan-04 5:18 
GeneralRe: Selected text in TreeNodes Pin
Anonymous31-Jan-04 2:37
Anonymous31-Jan-04 2:37 
QuestionAnyone Know a better way ? Pin
Guinness4Strength30-Jan-04 3:49
Guinness4Strength30-Jan-04 3:49 
AnswerRe: Anyone Know a better way ? Pin
Heath Stewart30-Jan-04 4:59
protectorHeath Stewart30-Jan-04 4:59 
GeneralRe: Path.Combine Pin
Mike Osbahr30-Jan-04 9:19
Mike Osbahr30-Jan-04 9:19 
GeneralRequest help for 2 newbie questions Pin
bouli30-Jan-04 3:06
bouli30-Jan-04 3:06 
GeneralRe: Request help for 2 newbie questions Pin
Wizard_0130-Jan-04 3:23
Wizard_0130-Jan-04 3:23 
GeneralRe: Request help for 2 newbie questions Pin
bouli30-Jan-04 3:31
bouli30-Jan-04 3:31 
GeneralRe: Request help for 2 newbie questions Pin
Mazdak30-Jan-04 3:40
Mazdak30-Jan-04 3:40 
GeneralRe: Request help for 2 newbie questions Pin
bouli30-Jan-04 3:42
bouli30-Jan-04 3:42 
GeneralRe: Request help for 2 newbie questions Pin
bouli30-Jan-04 3:54
bouli30-Jan-04 3:54 
GeneralRe: Request help for 2 newbie questions Pin
Mazdak30-Jan-04 4:32
Mazdak30-Jan-04 4:32 
GeneralRe: Request help for 2 newbie questions Pin
bouli30-Jan-04 4:36
bouli30-Jan-04 4:36 
GeneralRe: Request help for 2 newbie questions Pin
Mazdak30-Jan-04 4:45
Mazdak30-Jan-04 4:45 
GeneralRe: Request help for 2 newbie questions Pin
bouli30-Jan-04 5:08
bouli30-Jan-04 5:08 
GeneralRe: Request help for 2 newbie questions Pin
Heath Stewart30-Jan-04 4:51
protectorHeath Stewart30-Jan-04 4:51 
GeneralRe: Request help for 2 newbie questions Pin
Mazdak30-Jan-04 5:00
Mazdak30-Jan-04 5:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.