Windows Develop Bookmark and Share   
 index > Windows Forms General > TreeView label editing preempted after single character
 

TreeView label editing preempted after single character

In the following Form, a TreeNode's label edit operation ends after a single character is input, unless the child window is in front and not minimized.

When there are multiple MDI children, the first visible form in the MDI parent's MdiChildren array must be foremost and not minimized. I tried to programatically BringToFront() said form during label editing, but this still does not work 100% of the time.

What is causing this behavior and how can I prevent it?

public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
}
protected:
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::TreeView^ treeView1;
private: System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->treeView1 = (gcnew System::Windows::Forms::TreeView());
this->SuspendLayout();
//
// treeView1
//
this->treeView1->Dock = System::Windows::Forms::DockStyle::Left;
this->treeView1->LabelEdit = true;
this->treeView1->Location = System::Drawing::Point(0, 0);
this->treeView1->Name = L"treeView1";
this->treeView1->Size = System::Drawing::Size(200, 471);
this->treeView1->TabIndex = 0;
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(696, 471);
this->Controls->Add(this->treeView1);
this->IsMdiContainer = true;
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->ResumeLayout(false);

}
#pragma endregion

private:
System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
Form^ f = gcnew Form();
f->MdiParent = this;
f->Show();
f->WindowState = FormWindowState::Minimized;

TreeNode^ tn = this->treeView1->Nodes->Add("Top1");
tn->Nodes->Add("sub1");
tn->Nodes->Add("sub2");
tn = this->treeView1->Nodes->Add("Top2");
tn->Nodes->Add("sub3");
tn->Nodes->Add("sub4");
tn->Nodes->Add("sub5");
tn = this->treeView1->Nodes->Add("Top3");
tn->Nodes->Add("sub6");
tn->Nodes->Add("sub7");
tn->Nodes->Add("sub8");
this->treeView1->ExpandAll();
}
};

RSDuren  Tuesday, June 13, 2006 3:41 AM
Sorry, Peter. I missed your other post and thought my issue was forgotten.

The answer can be found at http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=472058

Ryan
RSDuren  Tuesday, June 13, 2006 12:09 PM

Hi RSDuren,

Based on my review, I found another similar issue in the forum.
I have replied to your another post in the forum please have a check.

If you still have any concern, please feel free to post here.

Best regards,
Peter Huang

Peter Huang - MSFT  Tuesday, June 13, 2006 8:47 AM
Sorry, Peter. I missed your other post and thought my issue was forgotten.

The answer can be found at http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=472058

Ryan
RSDuren  Tuesday, June 13, 2006 12:09 PM

You can use google to search for other answers

Custom Search

More Threads

• custom menu items
• RichTextBox Drag & Drop
• Append 2 byte[] arrays
• VS2008 flowpanlelayout inside tablelayoutpanel has no columnspan property
• multilanguage development in win forms application
• How to read a rich text file into a richtextbox.
• MDI Application in C#
• My app starts out minimized, how can I show a form?
• "Out Of Memory" when open large Tiff images (GDI+)
• MaskedTextBox