开发者

Starting WinForm From Clicking Gallery Item[DevExpress]

It trying to make it so when the user click the gallery item image that it will call the associated W开发者_运维百科inForm.

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.


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("...");
    }
}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜