我正在尝试使用4列构建Windows C ++ / CLR ListView:其中三个是固定宽度,但第一个我需要自动调整。这是代码:
int offset = 250;
int ypos = 35;
int size = 560;
int height = 185;
myListView = gcnew System::Windows::Forms::ListView();
myListView->Name = "MyListView";
myListView->Font = (gcnew System::Drawing::Font(L"Segoe UI", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
myListView->Location = System::Drawing::Point(offset, ypos - 25);
myListView->Size = System::Drawing::Size(size, height);
myListView->GridLines = true;
myListView->Sorting = System::Windows::Forms::SortOrder::Ascending;
myListView->View = System::Windows::Forms::View::Details;
myListView->HeaderStyle = System::Windows::Forms::ColumnHeaderStyle::Clickable;
myListView->Scrollable = true;
myListView->FullRowSelect = true;
myListView->MultiSelect = false;
myListView->Columns->Add("Name", -2, System::Windows::Forms::HorizontalAlignment::Left);
myListView->Columns->Add("Dir 1", 130, System::Windows::Forms::HorizontalAlignment::Left);
myListView->Columns->Add("Dir 2", 130, System::Windows::Forms::HorizontalAlignment::Left);
myListView->Columns->Add("Saved Date/Time", 130, System::Windows::Forms::HorizontalAlignment::Left);
我在-2
列使用Name
:
myListView->Columns->Add("Name", -2, System::Windows::Forms::HorizontalAlignment::Left);
我的较大元素位于第5列,如:
John
Mary
Peter
Paul
This is a autosize test
第5行被切断,并没有像我预期的那样调整整个列的大小,我不知道是什么原因造成的。
帮助appreacited。