|
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(); } };
|