从单击图库项目启动 WinForm[DevExpress]

发布于 2024-10-28 19:20:09 字数 147 浏览 6 评论 0原文

它试图做到这一点,以便当用户单击图库项目图像时,它将调用关联的 WinForm。

即:单击 RibbonGalleryBarItem1 中的图像调用关联的 winform。

汽车图像将启动汽车形式。任何有关如何执行此操作或类似操作的想法将不胜感激。

It trying to make it so when the user click the gallery item image that it will call the associated WinForm.

ie: Clicking the image from ribbonGalleryBarItem1 call the associated winform.

car image will start the car form. Any ideas on how to do this, or something like this would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烏雲後面有陽光 2024-11-04 19:20:09

处理ribbonGalleryBarItem1对象的GalleryItemClick事件。 e.Item 参数返回单击的项目。使用其属性,您应该能够确定单击了哪个项目并调用代码以显示所需的表单。

例如:

private void ribbonGalleryBarItem3_GalleryItemClick(object sender, DevExpress.XtraBars.Ribbon.GalleryItemClickEventArgs e) {
    switch(e.Item.Caption.ToLower()) { 
        case "car":
            ShowCarForm();
            break;
        case "plane":
            ShowPlaneForm();
            break;
        ...
        default:
            throw new NotSupportedException("...");
    }
}

Handle the GalleryItemClick event of the ribbonGalleryBarItem1 object. The e.Item parameter returns the clicked item. Using its properties, you should be able to determine which exactly item was clicked and invoke the code to show the required form.

For example:

private void ribbonGalleryBarItem3_GalleryItemClick(object sender, DevExpress.XtraBars.Ribbon.GalleryItemClickEventArgs e) {
    switch(e.Item.Caption.ToLower()) { 
        case "car":
            ShowCarForm();
            break;
        case "plane":
            ShowPlaneForm();
            break;
        ...
        default:
            throw new NotSupportedException("...");
    }
}
°如果伤别离去 2024-11-04 19:20:09

您需要创建一个处理程序来处理所有图像点击。
然后,需要定义一个方法来区分每次调用。
例如,按名称或按标签。

这实际上取决于您如何实现画廊及其内部的图像。
更多信息可以帮助您更好地了解如何解决您的问题。

我只能猜测您正在使用 PictureBoxes 来显示图像。如果是这种情况,那么您需要定义 Click 事件的处理程序并实现如下所示的内容:

private void PictureClicked(object sender, EventArgs e) {
    Control picture = sender as Control;
    if (picture == null) //just in case...
        return;
    switch (picture.Name) {
        case "pictureBoxCar":
            //open Car form
            break;
        case "pictureBoxBoat":
            //open Boat form
            break;
    }
}

您也可以使用 Tag 属性。但同样,这取决于您如何构建画廊。

希望这有帮助。

You need to create a handler that will handle all image clicks.
Then, you need to define a method to distinguish each call.
Either by name or by tag, for example.

It really depends on how you implemented the galleries and the images inside them.
More information can help better understand how to solve your problem.

I can only guess that you are using PictureBoxes to display your images. If it's the case, then you need to define the handler for Click event and implement something like this:

private void PictureClicked(object sender, EventArgs e) {
    Control picture = sender as Control;
    if (picture == null) //just in case...
        return;
    switch (picture.Name) {
        case "pictureBoxCar":
            //open Car form
            break;
        case "pictureBoxBoat":
            //open Boat form
            break;
    }
}

You can use the Tag property as well. But again, it depends on how you contruct your galleries.

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文