1

I have an application where I'd like to create multiple DockPanels at run-time, but I'd like them to all follow the same template.

I've had some success attempting this dynamically (creating the class in pure code) but the lack of designer features is seriously impeding my ability to make it aesthetically pleasing (it also feels like I'm working against the API, which usually means I'm doing something wrong).

p.s. I'm using DevExpress v13.1 and WinForms on the .NET 4.5 Framework

Jstone05
  • 61
  • 6
  • I think the DevEx API are very non-intuitive so *working against the API* is expected IMO. ;) – IAbstract Nov 18 '13 at 20:06
  • `aesthetically pleasing` - You're looking for WPF. – Federico Berasategui Nov 18 '13 at 20:23
  • Well, performance is a big deal in the app I'm building now. Me and my colleagues are under the impression that WPF performance leaves something to be desired, so winforms is a necessary evil in this case – Jstone05 Nov 18 '13 at 20:39
  • @Jstone05 performance concerns on WPF vs winforms are explained [here](http://stackoverflow.com/a/19642658/643085). To summarize, winforms sucks. WPF rules. – Federico Berasategui Nov 18 '13 at 21:11
  • I think the better answer is http://stackoverflow.com/a/19642453/210709 ...however, WPF doesn't just automatically answer your question and seems a bit off topic and some opinions should be left unsaid. Working with the DockPanels is a royal pain but provides a great user experience when managed properly. Can you post some samples of what you have tried? A screen shot and some of the code? – IAbstract Nov 18 '13 at 21:39
  • WPF may be worth exploring, and I'll give it a glance when I have the time. Regardless I need to explore both options and should WPF prove unusable I'd like to have an alternative prepared. For a sense of the performance we're talking about here my app currently processes ~20,000 entries a second in real time, and needs to make a solid attempt at handling 200,000/second (an extreme case, and only for a short duration, but still) – Jstone05 Nov 18 '13 at 22:01
  • @IAbstract yes, WPF automatically avoids all the horrible hacks and torture and pain and tons of "owner draw" crap it takes do to anything useful in winforms. – Federico Berasategui Nov 19 '13 at 03:35
  • @JStone05 If you're dealing with large collections of data, you might want to see [this short clip](http://www.youtube.com/watch?v=D3Y6DnFpHCA) – Federico Berasategui Nov 19 '13 at 03:35
  • @HighCore While that's interesting our experience is quite different here. Now I'm not the WPF "guy" here, but when comparing his test-app against mine (WinForm vs. WPF) mine could post, in real time, data as fast as the system was able to create it (33 mil. entries in 20 seconds before hitting the memory cap for our systems). His Conversely would go not-responding well before than. – Jstone05 Nov 23 '13 at 19:01
  • @Jstone without knowing what you're talking about in depth, I cannot tell you the cause of that, but one thing is for sure. winforms sucks. WPF rules. period. WPF has built in UI virtualization, which makes it really good at handling large collections of data. winforms has built in flicker and incapabilities and lack of customizability and uselessness. – Federico Berasategui Nov 23 '13 at 19:31
  • @HighCore We've simply got an endless loop (in a worker thread) constantly adding data to a list, which is then displayed with a gridview. Our largest concern is the performance of real-time adds to this grid. I'd love to use WPF, so if you can point me in the direction of a implementation that could handle this that'd be great, but simply stating it's possible without any sort of direction is of very little use to me. Also note that I am using the Devexpress gridview so UI visualization is included (https://www.devexpress.com/Support/Center/Question/Details/Q482410) – Jstone05 Nov 23 '13 at 19:57
  • @Jstone05 have you seen [my Log Viewer](http://stackoverflow.com/a/16745054/643085) example? it has a timer which adds "Log Entries" to a collection every 100 ms, I just tested changing that to 1ms and the UI still works the same. WPF does not really care how fast you update your collection because the UI is virtualized, thus kept intact until you scroll or something. Go ahead and try my example with 1ms Timer and see the results for yourself. – Federico Berasategui Nov 23 '13 at 20:10
  • @Jstone05 not to mention you can actually create a **Rich** UI in WPF, as opposed to winforms that only supports `poor` stuff. – Federico Berasategui Nov 23 '13 at 20:14
  • @HighCore Thanks for that, I'll pass it along to my boss and see if we can pivot to WPF, I'm not the WPF guy at our company so all I've got no idea if we'll be able to integrate it into our project, but I definitely feel it's the better choice. – Jstone05 Nov 25 '13 at 16:35

1 Answers1

1

There are simple steps how to create reusable UI portion in Win Forms and place it into multiple Dock Panels:

  1. Create UserControl (VS menu Project->Add UserControl...) that contains all needed UI stuff via the designer.
  2. Rebuild the solution -> UserControl will appear in the Toolbox.
  3. Drop this UserControl onto specific Dock Panel.
  4. Repeat Step 3 for each Dock Panel. Profit!!!

At runtime, just create this UserControl instances and place it onto runtime-created Dock Panels.

Community
  • 1
  • 1
DmitryG
  • 17,677
  • 1
  • 30
  • 53