优化单元格进入编辑状态后,能跟随区域移动
This commit is contained in:
@@ -77,7 +77,14 @@ void mainForm::OnNotify(Control* sender, EventArgs& args)
|
||||
// 表格增加一行数据
|
||||
tableView->InsertRow(rowCount);
|
||||
tableView->SetRowData(rowCount, { L"uid" + std::to_wstring(rowCount), L"192.168.200.131\n127.0.0" , L"", L"2026-02-25"});
|
||||
// 获取表格指定位置数据
|
||||
tableView->SetCellChecked(rowCount, 5, true);
|
||||
tableView->SetCellComboIndex(rowCount, 2, 0);
|
||||
|
||||
// 改变单元格颜色
|
||||
/*CellStyle style = tableView->GetCellStyle(1, 1);
|
||||
style.SetBackColor(Color(200, 230, 155));
|
||||
tableView->SetCellStyle(1, 1, style);*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +118,7 @@ void mainForm::OnClose(bool& close)
|
||||
Application::Exit();
|
||||
}
|
||||
|
||||
mainForm::mainForm() :LayeredWindow(1000, 750)
|
||||
mainForm::mainForm() :LayeredWindow(1400, 750)
|
||||
{
|
||||
SetResizable(true); // 启用窗口大小调整
|
||||
SetMiniSize(Size(600, 450)); // 设置最小尺寸
|
||||
@@ -128,17 +135,16 @@ mainForm::mainForm() :LayeredWindow(1000, 750)
|
||||
TableView* tableView = (TableView*)FindControl("tableViewAdmin"); //获取表格控件
|
||||
if (tableView) {
|
||||
tableView->SelectedRowBackColor = Color(200, 230, 255); // 设置选中行背景色
|
||||
tableView->SetColumnType(5, ezui::CellType::CheckBox);
|
||||
//tableView->SetColumnType(5, ezui::CellType::CheckBox);
|
||||
tableView->SetColumnType(2, ezui::CellType::ComboBox);
|
||||
tableView->SetColumnComboItems(2, { L"默认", L"禁止" , L"验机" });
|
||||
tableView->SetDefaultTextAlign(Align::MiddleCenter);
|
||||
|
||||
//设置列宽
|
||||
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++)
|
||||
for(int i = 0; i < withs.size(); i++)
|
||||
tableView->SetColumnWidth(i, withs[i]);
|
||||
|
||||
|
||||
// 鼠标右键单击的回调
|
||||
tableView->RightClick = [tableView](int row, int col) {
|
||||
int pRow = tableView->GetHoverRow(); //当前行号
|
||||
@@ -150,7 +156,7 @@ mainForm::mainForm() :LayeredWindow(1000, 750)
|
||||
|
||||
// 单元格编辑完成(编辑结束时触发,提供旧值与新值)
|
||||
tableView->CellEditFinished = [](int row, int col, const UIString& oldValue, const UIString& newValue) {
|
||||
std::cout << "单元格内容: " << newValue.ansi() << ", " << oldValue.ansi() << std::endl;
|
||||
std::cout << "完成编辑单元格内容: " << newValue.ansi() << ", " << oldValue.ansi() << std::endl;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user