简体   繁体   中英

Devexpress NavigationBar Item Onclick to load Grid into GridControl

I am a newbie to devexpress , I really need help on how to manage NavBarControl item. When Navbar item onclick event is fired I want to load a GridView into gridControl .

For example. Let say I have two item/link in Group A which are link 1 and link 2 , when Group A - Link 1 is clicked I want to load gridview1 into gridControl1 and if Link 2 is clicked load gridView2 to gridControl

How can I achieve this?

When Navbar item onclick event is fired I want to load a GridView into gridControl.

Take a look at the NavBarControl.LinkClicked event. You can handle this event as follows(use the e.Link property to detect the specific link):

navBarControl1.LinkClicked += navBarControl1_LinkClicked;
//...
void navBarControl1_LinkClicked(object sender, NavBarLinkEventArgs e) {
    if(e.Link.Item == navBarItem1)
        gridControl1.MainView = gridView1;
    if(e.Link.Item == navBarItem2)
        gridControl1.MainView = cardView1;
}

Or you can handle the corresponding NavBarItem.LinkClicked event for the specific items:

navBarItem1.LinkClicked += navBarItem1_LinkClicked;
navBarItem2.LinkClicked += navBarItem2_LinkClicked;
//...
void navBarItem1_LinkClicked(object sender, NavBarLinkEventArgs e) {
    gridControl1.MainView = gridView1;
}
void navBarItem2_LinkClicked(object sender, NavBarLinkEventArgs e) {
    gridControl1.MainView = cardView1;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM