design-time

C# Windows Forms Design-time Form constructor not called?

三世轮回 提交于 2019-12-02 19:06:20
问题 Is the constructor of a form not called upon opening the form in design view? Why not? Can I somehow force it to be called? I tested it by showing a MessageBox in the constructor, and only the MessageBox from the constructor of the form's base type (another form) is shown... 回答1: This behavior is by design. The form designer in Visual Studio cannot instantiate the class being designed — instead, it instatiates its immediate parent. There is no way to change this behavior. If you need some

C# Windows Forms Design-time Form constructor not called?

老子叫甜甜 提交于 2019-12-02 10:23:46
Is the constructor of a form not called upon opening the form in design view? Why not? Can I somehow force it to be called? I tested it by showing a MessageBox in the constructor, and only the MessageBox from the constructor of the form's base type (another form) is shown... This behavior is by design. The form designer in Visual Studio cannot instantiate the class being designed — instead, it instatiates its immediate parent. There is no way to change this behavior. If you need some logic to be executed during design time, you have to create a separate ancestor encapsulating that logic and

Can't edit Point[] or List<Point> at design time

落花浮王杯 提交于 2019-12-01 19:38:35
I'm creating custom control that will draw shape from list (or array) of points. I have basic drawing functionality done, but now I'm struggling with design-time support in Visual Studio. I've created two properties: private Point _point; public Point Point { get { return _point; } set { _point = value; } } private Point[] _points; public Point[] Points { get { return _points; } set { _points = value; } } As seen on screen below Point is editable, but editor for Points isn't working. For each property I get error Object does not match target type. If I change Point to MyPoint (custom class

How do I provide designer support to a TabControl residing in a UserControl, so that I can drag/drop controls onto tab pages?

不想你离开。 提交于 2019-12-01 12:05:10
问题 I have a user control, which contains both a Panel and a TabControl. I enabled design-time support for both. I can drag/drop controls from the toolbox onto the Panel control that resides within the user control. I can also add and remove tab pages via the designer on the TabControl. However, I am not able to drag/drop any controls onto the tab pages themselves. Below is the code generated source code for my user control: partial class TestUserControl { private System.ComponentModel.IContainer

How do I debug a designtime package unloading crash involving a crash in ThreadProc in Classes.pas?

六月ゝ 毕业季﹏ 提交于 2019-12-01 09:01:05
I am not sure how to track down the following crash: It happens when Unloading a Designtime Package that is used in-house at my company. It is our code, thus it is our bug to fix, not a third party component vendor problem. It apppears that a thread is involved, but since it happens in the Function ThreadProc in Classes.pas, I'm guessing it's a bare System/RTL thread without even a TThread class wrapper that I should be searching for in our code. (Question Part A: Is that so?) The call stack contains none of my code, only the IDE itself, and the base function in the call stack is ntdll

How do you debug a WPF user control in design mode?

风流意气都作罢 提交于 2019-12-01 01:17:44
问题 I have a wpf user control I created that contains a label. The label's foreground setting changes based on some code that checks a number of conditions. The label in my control is displaying the wrong color at design time but I cannot figure out how to debug my user control at design time so that I can have it catch breakpoints (and thus figure out where my logic is flawed). The color on the control is correct at run-time, it is only at design time that it is displayed incorrectly. 回答1: Here

Can a Windows Forms control have a Design Time-only property?

回眸只為那壹抹淺笑 提交于 2019-11-30 23:56:25
I wish to allow the user of my control to choose the licensing method for the control. The choice comes from an enumeration, so they must choose one of the methods I have laid out for them. This license needs to be chosen prior to the code executing at runtime. Therefore I wish for them to selected a value at design time. Furthermore I do not wish for this property to be writable at runtime, if that can be avoided. Is there a way to make a property only available at design time? You can give a control design-time behavior by creating a separate designer class for the control. Since the control

Visual Studio Design Time Property - Form List Drop Down

你说的曾经没有我的故事 提交于 2019-11-30 21:45:23
[EDIT] To be clear, I know how to get a list of forms via reflection. I'm more concerned with the design time property grid. I have a user control with a public property of the type Form. I want to be able to select a form at design time from a dropdown. I want to populate the form dropdown list from a set namespace: UI.Foo.Forms This would work like if you have a public property of Control. At design time, the property will automatically populate a dropdown with all the controls on the form, for you to select from. I just want to populate it with all the forms in a namespace. How do I go

KeyedCollection and d:DataContext Design Error

本小妞迷上赌 提交于 2019-11-30 15:58:04
See the update below for VS2013. When using a class as a d:DesignInstance that exposes a KeyedCollection<TKey, TItem> , the XAML designer complains with the following warning: The number of generic arguments provided doesn't equal the arity of the generic type definition. Parameter name: instantiation The problem can be reproduced with the following simple program: <Window x:Class="Test.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns

Adding design-time support for a nested container in a custom/usercontrol (Winforms)

百般思念 提交于 2019-11-30 14:39:57
I have something similar to a wizard control, in the middle is a Panel I would like to use to place any child controls. I have found using the ScrollableControlDesigner will allow dropped controls to be added to the custom/usercontrol, but this is not what I require. It needs to be added to the container, so layout can be applied without affecting the 'outer' controls (heading, navigation buttons). I have tried various ways, that did not work, and looked hacky. Any ideas? I found the answer here ! The key is ControlDesigner.EnableDesignMode() . 来源: https://stackoverflow.com/questions/594808