windows-forms-designer

How can I override behavior of DockStyle Editor in PropertyGrid

二次信任 提交于 2019-12-08 01:36:41
问题 We have a custom panel which inherits Panel and has an Orientation property implemented similarly to the SplitContainer Orientation property. For our custom panel, DockStyle.Fill is never valid and depending on the Orientation property value, DockStyle needs to be Left or Right for Vertical or Top or Bottom for Horizontal. The DockStyleEditor class is sealed so we can't subclass it for our own custom UITypeEditor. Is there a way to override certain behaviors using a TypeDescriptor or some

Is it possible to change a component name in a component designer in WinForms .Net

笑着哭i 提交于 2019-12-07 17:33:45
问题 I've created a component whose name I'd like to be able to change while editing in the component tray. I've added a Designer action for a name property, but now I'm stuck. Looking at the property grid, I can see that the name property is parenthesised, indicating that it's not a regular property. Is this possible? 回答1: You can change the name of a Component at design-time using Component.Site.Name . You should put the code in a try/catch block to handle exception when the name is duplicate.

How to show a form on current screen in C#?

柔情痞子 提交于 2019-12-07 13:15:46
问题 I want to show a new form in the same window from where it was invoked. I know a way to show this form on PrimaryScreen or Virtual Screen by code similar to as below: MyForm.Location = Screen.PrimaryScreen.Bounds.Location; But i want to show it on current screen. Is there a way to find out and show it on current screen? 回答1: I have done something like this to show my form centered to the current screen: var screen = Screen.FromPoint(Cursor.Position); myForm.StartPosition = FormStartPosition

C# WindowsForms UserControl's Controls Designer Support

末鹿安然 提交于 2019-12-07 11:33:49
问题 What I am looking for is the same type of designer support for controls inside a usercontrol. ie - resizing a textbox, moving a label, that are inside a usercontrol after placeing the usercontrol on to a form . What I've been able to do... create a usercontrol use the designer to add controls to the it create a new window forms app add the usercontrol to the toolbox drag and drop the control on the a form where I am stuck... edit the usercontrols controls. IE - being able to resize a textbox

How to obtain ITypeDescriptorContext and IServiceProvider in inherited ControlDesigner class

↘锁芯ラ 提交于 2019-12-07 01:50:12
问题 I have inherited ControlDesigner class into MyControlDesigner . In this class I need to obtain objects behind ITypeDescriptorContext and IServiceProvider interfaces, but I don't know how :( I need these 2 interfaces to pass them in method, but I can't find them inside any other object. Can somebody please help me. Thank you Best regards Bojan 回答1: There is an internal class EditorServiceContext in System.Design assembly which has implemented ITypeDescriptorContext , IServiceProvider and

Form designer breaks on generic abstract UserControl

廉价感情. 提交于 2019-12-07 01:38:36
问题 I have a generic abstract UserControl class, SensorControl , which I want all my sensor control panels to inherit from. The problem When attempting to design the EthernetSensorControl (one of my inherited UserControl forms, from within Visual Studio, the following error is displayed in the form designer: The designer could not be shown for this file because none of the classes within it can be designed. The designer inspected the following classes in the file: DeviceSensorControl --- The base

Drag and Drop Function with Drawing Rectangle C# .net - Forms

本秂侑毒 提交于 2019-12-07 01:03:29
I want to drag and drop that I have drawn on the forms. Here is my code for drawing the rectangle. An this works fine. Rectangle rec = new Rectangle(0, 0, 0, 0); public Form1() { InitializeComponent(); this.DoubleBuffered = true; } protected override void OnPaint(PaintEventArgs e) { e.Graphics.FillRectangle(Brushes.Aquamarine, rec); } protected override void OnMouseDown(MouseEventArgs e) { if (e.Button == MouseButtons.Left) { rec = new Rectangle(e.X, e.Y, 0, 0); Invalidate(); } } protected override void OnMouseMove(MouseEventArgs e) { if (e.Button == MouseButtons.Left) { rec.Width = e.X - rec

How to Develop a Desktop Application using C# which can Utilize USB Barcode Scanner. How to start

萝らか妹 提交于 2019-12-06 14:30:50
问题 I have gone through Microsoft Developer website. There is development using pointOfService. but I am getting error in: scanner = await BarcodeScanner.GetDefaultAsync(); SAYING: IAsyncOperation does not contain definition for GetAwaiter May be I am missing any Reference but not sure which one. If there is any other way to do please share it. And one Important thing I am developing Windows Desktop Application. Complete Code is: private async Task<bool> CreateDefaultScannerObject() { if (scanner

Datagridview Updating

China☆狼群 提交于 2019-12-06 13:55:16
问题 How to update the DataGridView so that it will effect the changes in database too? The code which I am trying is: foreach (DataGridViewRow myDgrow in dataGridView2.Rows) { myCmd = "Update Details set ProjectName='" + myDgrow.Cells["ProjectName"].Value + "', Description = '" + myDgrow.Cells["Description"].Value + "', DateStarted='" + myDgrow.Cells["DateStarted"].Value + "',TeamSize='" + myDgrow.Cells["TeamSize"].Value + "',Manager='" + myDgrow.Cells["Manager"].Value + "'"; myCmd = "Update

Real Hint in TextBox Visual Studio C# [duplicate]

霸气de小男生 提交于 2019-12-06 12:59:09
This question already has answers here : Watermark TextBox in WinForms (8 answers) Closed last year . I'm currently making a Windows Forms Application on Visual Studio in C# and I'm trying to find a way to have a real hint . I've found a lot of answers online on how to have some text preset there, Some examples even show how to grey out the text to look like a placeholder, but that's not what I'm looking for. I want a grayed out text that you don't have to backspace to type something there. So I want it to behave like an HTML placeholder like the "Search Q&A" search bar on stack Overflow. Is