添加ComboBox的xml实现
This commit is contained in:
@@ -118,30 +118,34 @@ void mainForm::OnClose(bool& close)
|
||||
Application::Exit();
|
||||
}
|
||||
|
||||
mainForm::mainForm() :LayeredWindow(1400, 750)
|
||||
mainForm::mainForm() :LayeredWindow(1500, 750)
|
||||
{
|
||||
SetResizable(true); // 启用窗口大小调整
|
||||
SetMiniSize(Size(600, 450)); // 设置最小尺寸
|
||||
umg.LoadXml("res/mainForm.htm");//加载xml里面的控件与样式
|
||||
umg.SetupUI(this);
|
||||
|
||||
// 如果是debug模式则创建控制台窗口用于输出调试信息
|
||||
#ifdef _DEBUG
|
||||
AllocConsole();
|
||||
FILE* fp = nullptr;
|
||||
freopen_s(&fp, "CONOUT$", "w", stdout);
|
||||
freopen_s(&fp, "CONOUT$", "w", stderr);
|
||||
|
||||
std::cout << "调试模式控制台已启动!" << std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
// 初始化设置表格各项属性
|
||||
TableView* tableView = (TableView*)FindControl("tableViewAdmin"); //获取表格控件
|
||||
if (tableView) {
|
||||
tableView->SelectedRowBackColor = Color(200, 230, 255); // 设置选中行背景色
|
||||
//tableView->SetColumnType(5, ezui::CellType::CheckBox);
|
||||
tableView->SetColumnType(2, ezui::CellType::ComboBox);
|
||||
tableView->SetColumnComboItems(2, { L"默认", L"禁止" , L"验机" });
|
||||
tableView->SetDefaultTextAlign(Align::MiddleCenter);
|
||||
tableView->SetColumnType(2, ezui::CellType::ComboBox); //设置第3列为下拉列表类型
|
||||
tableView->SetColumnComboItems(2, { L"默认", L"禁止" , L"验机" }); //设置第3列下拉列表内容
|
||||
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};
|
||||
std::vector<int> withs = {60, 130, 55, 95, 85, 85, 105, 70, 75, 80, 80, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95 };
|
||||
for(int i = 0; i < withs.size(); i++)
|
||||
tableView->SetColumnWidth(i, withs[i]);
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace ezui {
|
||||
|
||||
VListView m_list;
|
||||
int m_index = -1;
|
||||
int m_pendingIndex = -1; // 延迟设置的索引(用于XML属性解析)
|
||||
void Init();
|
||||
protected:
|
||||
virtual void OnLayout()override;
|
||||
@@ -47,5 +48,7 @@ namespace ezui {
|
||||
//添加一个item并返回新item的下标
|
||||
int AddItem(const UIString& text);
|
||||
void RemoveItem(int index);
|
||||
//设置属性
|
||||
virtual void SetAttribute(const UIString& key, const UIString& value)override;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -255,14 +255,29 @@ namespace ezui {
|
||||
// 选中行背景色(当第一列为CheckBox且被选中时使用,或者单击选中行时使用)
|
||||
Color SelectedRowBackColor = Color(0xFFADD8E6); // 浅蓝色
|
||||
|
||||
/*
|
||||
table->CellValueChanged = [](int row, int col, const UIString& value) {
|
||||
// 处理内容变化
|
||||
};
|
||||
*/
|
||||
// 单元格内容变化回调(内容变化时立即触发)
|
||||
// 参数: row, col, newValue
|
||||
std::function<void(int, int, const UIString&)> CellValueChanged = nullptr;
|
||||
|
||||
|
||||
/*
|
||||
table->CellEditFinished = [](int row, int col, const UIString& oldValue, const UIString& newValue) {
|
||||
// 处理内容变化
|
||||
};
|
||||
*/
|
||||
// 单元格编辑完成回调(编辑结束时触发,比如TextBox失去焦点或按Enter时)
|
||||
// 参数: row, col, oldValue, newValue
|
||||
std::function<void(int, int, const UIString&, const UIString&)> CellEditFinished = nullptr;
|
||||
|
||||
/*
|
||||
tableView->RightClick= [tableView](int row, int col) {
|
||||
// 处理内容变化
|
||||
};
|
||||
*/
|
||||
// 鼠标右键单击回调
|
||||
// 参数: row, col (row=-1 表示点击在表头,col=-1 表示点击在第一列)
|
||||
std::function<void(int, int)> RightClick = nullptr;
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user