Free cookie consent management tool by TermsFeed Policy Generator

Version 1 (modified by mkofler, 13 years ago) (diff)

Tried to document Michael Kommenda's View HowTo

Views in HL3


  • View
  • Content

Methods to override:

public new Algorithm Content {
get { return (T)base.Content; }
set { base.Content = value; }

protected override void OnContentChanged() { 
  if (Content != null) {
    // set controls to Content values
  } else {
    // set default values in controls

protected override void RegisterContentEvents() {

protected override void DeRegisterContentEvents() {

Events happen asynchronous --> Invoke required.

Views must still work if content is NULL.

private void Content_XYZChanged(object sender, System.EventArgs e) {
  if (InvokeRequired) {
    Invoke(new EventHandler(Content_ExecutionStateChanged), sender, e);
  } else {
    // set controls 


In principle all Views have 2 possible states:

  • Locked:
  • ReadOnly: cf. Results --> those can't be changed; this is not configured in the object graph but in the views
  • Either via ViewHost or manually

OnContentChanged --> update content here SetEnabledStateOfControls --> only update enabled and readonly here

Default Views:

  • The most specific default view is used for inherited classes.

protected override void SetEnabledStateOfControls() {



You should make sure that if CanChangeName is false --> ReadOnly

private void Content_NameChanged(object sender, EventArgs e) {

if (InvokeRequired) {


} else {



AsynchronosContentView, ItemView --> derive from those, not from ContentView or other views in MainForm.WindowsForm (uses Invoke synchronous --> can get messy).

Andreas has prepared a useful snippet that you may use to easily create a template for your view.

General advice:

If you program views that are not sealed --> make everything protected to allow inheritance.

Attachments (3)

Download all attachments as: .zip