简体   繁体   中英

Tab control + DataGridView in WinForms

I have multiple results sets coming back from a server request against a datasource. I want to organise these with a WinForms tabPage for each result set, on a single tabControl. I am displaying the data in a DataGridView, but want to avoid having a DataGridView instance on each tabPage - I'd rather intercept the "switching to new tab page" message, and load up the appropriate results set from my local cache. Is there an easy/obvious way to do this?

Create a tab control as usual and then put a DataGridView on top of it (be sure not to put it inside a tab page).

Subscribe to the SelectedIndexChanged event and reload the data when the event fires.

Why would you want to do this? You'd lose the designability per result set (unless they're all the same structure) and have to manage all of this yourself.

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