Search code examples
c#eyeshot

How to handle error ": 'Control's handle must be created first.'"?


I ran into an error Control's handle must be created first. The code returns the error

  model1.SetView(viewType.Trimetric, true, false);

I already tried model1.CreateControl(); before the code above executed but still same error.


Solution

  • You need to move the SetView() method call in the Form.OnLoad() (WinForms) or Window.OnContentRendered() (WPF) when the Model control is ready to be used.