表格新增右键单击回调函数
This commit is contained in:
@@ -8,26 +8,20 @@ void mainForm::OnNotify(Control* sender, EventArgs& args)
|
||||
Event eventType = args.EventType; // 事件类型
|
||||
|
||||
// 针对管理界面的表格控件
|
||||
if (btnName == "tableViewAdmin") {
|
||||
switch (eventType)
|
||||
{
|
||||
case 8: break;
|
||||
case Event::OnMouseUp://鼠标抬起
|
||||
{
|
||||
TableView* tableView = (TableView*)FindControl("tableViewAdmin"); //获取表格控件
|
||||
int pRow = tableView->GetHoverRow(); //当前行号
|
||||
int pCol = tableView->GetHoverCol(); //当前列号
|
||||
std::cout << "当前行列号: (" << pRow << ", " << pCol << ")\n";
|
||||
UIString celContent = tableView->GetData(pRow, pCol);
|
||||
std::cout << "单元格内容: " << celContent.ansi() << std::endl;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
std::cout << "表格事件:" << (long long)eventType << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//if (btnName == "tableViewAdmin") {
|
||||
// switch (eventType)
|
||||
// {
|
||||
// case 8: break;
|
||||
// case Event::OnMouseUp://鼠标抬起
|
||||
// {
|
||||
// TableView* tableView = (TableView*)FindControl("tableViewAdmin"); //获取表格控件
|
||||
// }
|
||||
// break;
|
||||
// default:
|
||||
// std::cout << "表格事件:" << (long long)eventType << std::endl;
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
|
||||
switch (eventType)
|
||||
{
|
||||
@@ -138,7 +132,24 @@ mainForm::mainForm() :LayeredWindow(1000, 750)
|
||||
tableView->SetColumnComboItems(2, { L"默认", L"禁止" , L"验机" });
|
||||
//设置列宽
|
||||
//std::vector<int> withs = {80, 100};
|
||||
|
||||
|
||||
|
||||
// 鼠标右键单击的回调
|
||||
tableView->RightClick = [tableView](int row, int col) {
|
||||
int pRow = tableView->GetHoverRow(); //当前行号
|
||||
int pCol = tableView->GetHoverCol(); //当前列号
|
||||
UIString celContent = tableView->GetData(pRow, pCol);
|
||||
//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;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
mainForm::~mainForm()
|
||||
|
||||
@@ -253,6 +253,10 @@ namespace ezui {
|
||||
// 参数: row, col, oldValue, newValue
|
||||
std::function<void(int, int, const UIString&, const UIString&)> CellEditFinished = nullptr;
|
||||
|
||||
// 鼠标右键单击回调
|
||||
// 参数: row, col (row=-1 表示点击在表头,col=-1 表示点击在第一列)
|
||||
std::function<void(int, int)> RightClick = nullptr;
|
||||
|
||||
public:
|
||||
TableView(Object* parentObject = nullptr);
|
||||
virtual ~TableView();
|
||||
|
||||
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