简体   繁体   中英

Make dynamically number of tab pages with ZedGraph in WinForm C#

I have data for several days. I want to plot that data, one day in one tab page. The tab page can change dynamically corresponding with the number of the day.

Previously, I always make a static page in the design mode. I use ZedGraph control to plot the data. I decided how many pages that I need. Then it means the number of pages is static.

Now, I need more dynamically. I want the number of tab pages can change dynamically. Each page has similar controls inside it. How to do that? I have no clue about it.

First you create a new class of type UserControl . These are meant to act as containers for controls. Then you put everything on it you need in your typical tabpage including the ZedGraph control..

Also write your logic there.

Now, when you need another page you create one and add a new instance of the UC class you have created.

You should think a little about dependencies with the rest of you application, including the deleting of the pages; a page controller class comes to mind that can handle these things, if necessary.

You could also subclass a tabpage but going the UC way gives go an additional layer of independency; you could place the same UC on a form or inside a container control..

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