优化编辑框控件的多行编辑和显示;

优化表格控件单元格的多行编辑和显示效果
This commit is contained in:
睿 安
2026-01-28 22:27:21 +08:00
parent 4fe4749826
commit 814f42120c
18 changed files with 78 additions and 43 deletions

View File

@@ -76,7 +76,7 @@ void mainForm::OnNotify(Control* sender, EventArgs& args)
int rowCount = tableView->GetRowCount(); //总行数
// 表格增加一行数据
tableView->InsertRow(rowCount);
tableView->SetRowData(rowCount, { L"uid" + std::to_wstring(rowCount), L"192.168.200.131" , L"默认"});
tableView->SetRowData(rowCount, { L"uid" + std::to_wstring(rowCount), L"192.168.200.131\n127.0.0" , L"", L"2026-02-25"});
// 获取表格指定位置数据
}
@@ -123,6 +123,7 @@ mainForm::mainForm() :LayeredWindow(1000, 750)
freopen_s(&fp, "CONOUT$", "w", stdout);
freopen_s(&fp, "CONOUT$", "w", stderr);
// 初始化设置表格各项属性
TableView* tableView = (TableView*)FindControl("tableViewAdmin"); //获取表格控件
if (tableView) {
@@ -130,12 +131,14 @@ mainForm::mainForm() :LayeredWindow(1000, 750)
tableView->SetColumnType(5, ezui::CellType::CheckBox);
tableView->SetColumnType(2, ezui::CellType::ComboBox);
tableView->SetColumnComboItems(2, { L"默认", L"禁止" , L"验机" });
//设置列宽
//std::vector<int> withs = {80, 100};
std::vector<int> withs = {60, 120, 50, 90, 85, 85, 100, 70, 70, 80, 80, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90};
for(auto i=0;i< withs.size();i++)
tableView->SetColumnWidth(i, withs[i]);
// 鼠标右键单击的回调
// 鼠标右键单击的回调
tableView->RightClick = [tableView](int row, int col) {
int pRow = tableView->GetHoverRow(); //当前行号
int pCol = tableView->GetHoverCol(); //当前列号
@@ -143,6 +146,7 @@ mainForm::mainForm() :LayeredWindow(1000, 750)
//std::cout << "单元格内容: " << celContent.ansi() << std::endl;
std::cout << "当前列宽: " << tableView->GetColumnWidth(pCol) << std::endl;
};
// 单元格编辑完成(编辑结束时触发,提供旧值与新值)
tableView->CellEditFinished = [](int row, int col, const UIString& oldValue, const UIString& newValue) {
std::cout << "单元格内容: " << newValue.ansi() << ", " << oldValue.ansi() << std::endl;