custom-controls

Custom ListBox with transparent backcolor issue

旧时模样 提交于 2019-12-25 01:55:18
问题 I created a custom multiline ListBox control inherited from ListBox. In the form, the ListBox position is above a WPF rounded and transparent panel hosted in an ElementHost. Now, what I want, is that ListBox backcolor to be transparent. Obviously, this is not allowed in Winforms, a ListBox cant be transparent. Then, I have tried some things, but there is always an issue. What I want to achieve is this: As you can see, this works perfectly, but actually I´m having two problems. The first I get

Why is Me.components Nothing?

丶灬走出姿态 提交于 2019-12-25 01:49:52
问题 I have written a custom ErrorProvider which adds some functionality to the existing ErrorProvider (sets control BackColor, ErrorCount etc). This was working find but now for some reason it falls over on the constructor: _LoginErrorProvider = New ErrorLogErrorProvider(Me.components) The error is a NullReferenceException which is caused by the fact that Me.components is Nothing. Can anyone shed any light on why a form's components collection would be Nothing? The form seems to work fine in

Windows Forms custom control: focus and cursor keys without UIPermissionWindow.AllWindows

倾然丶 夕夏残阳落幕 提交于 2019-12-25 01:44:44
问题 I want to write a custom control (a text editor) for Windows Forms, which should include the following functionality: Gets the keyboard focus, when you click on it with the mouse Sees all keyboard input (including cursor keys), when it has the focus, Can run in a semi-trusted environment, with UIPermissionWindow.SafeTopLevelWindows (i.e. it shouldn't require UIPermissionWindow.AllWindows ) Is there any example of doing this? Some of the methods which I might want to use, like Control.Focus()

Why does the designer slowing when two custom controls has timer added?

家住魔仙堡 提交于 2019-12-24 16:51:54
问题 I have a custom control that is used for long time processes. This control has spinning circles around a point. To do this, I am using timer that is working on design time and run-time. When one control is added to form there is no problem. But two of them are added to form, the designer slows down so much. Why does this problem occurs and how can I fix it? My code from this project: public class SpinningCircles : Control { bool fullTransparency = true; int increment = 1; int radius = 4; int

Why isn't my user control paint event filling my rectangle only on one control?

我们两清 提交于 2019-12-24 16:12:10
问题 I can't understand what I'm doing wrong. For one of the two controls I create (the first one) it works. But for the second one, it doesn't? I've tried many things to fix this but I haven't come any closer to a solution any ideas? What happens Code where they are created: public MessageLogView() { MessageBubble bubble = new MessageBubble("Hey there Steve I love you", DateTime.Today, Color.FromArgb(255,255,255), new Padding(10, 10, 10, 10)); bubble.Location = new Point(5, 5); this.Controls.Add

Click event handler with Custom Control Button

▼魔方 西西 提交于 2019-12-24 14:30:41
问题 I'm creating an ASP.NET Custom Control for my web application which is basically an ASP.NET Button control contained inside multiple <div> elements (for styling purposes). How can I create a Click event handler for my custom control so that my control acts as an ASP.NET Button? Ie. <cc:Button id="myButton" runat="server" Text="Submit" /> Sub myButton_Click(sender as object, e as EventArgs) Handles myButton.Click End Sub 回答1: In the code behind, declare an event in your class: Public Event

How to develop a custom window which will have all the Properties of general window using WPF

狂风中的少年 提交于 2019-12-24 11:53:40
问题 I am going to develop my own window where I'll have my own Caption Buttons (Minimize, Maximize, Restore and Close) and all the properties related to these buttons and can add any control at the title position of the window. Suggest me the way how I'll proceed for it please...... Thanks in advance 回答1: My suggestion is NOT to do it. This is not needed in WPF. Simply change the Window template and you'll get what you ask. Edit: Here is an example. <ResourceDictionary x:Class="MyNamespace

What is best way to store controls and add controls dynamically to a existing form

和自甴很熟 提交于 2019-12-24 09:28:18
问题 I have a generic form which shows default controls. I'm trying to build a form queue where if we have a client that wants extra data, I would like to store asp.net controls required to capture data for each client and load them dynamically along with default form. Does anybody know or direct me to a architecture/solution to implement this[store the forms and load and add them dynamically to existing form and retrieve data from them passed]. My initial thought was to use xml file for each

How to persist design time property changes that were made programmatically?

微笑、不失礼 提交于 2019-12-24 05:43:51
问题 I have a custom control that I added an Id string property to. When the control is placed on a form, I want the constructor to set this to Guid.NewGuid().ToString() , but only if it hasn't been set before. When I manually edit this property from the designer, it adds a line of code to the Designer.cs file. How can I do that programmatically? Specifically, how to do it from within the custom control? 回答1: I have created sample usercontrol that fits your requrements. In this case is "MyLabel"

.NET WinForms Custom Control: how to get a reference to the containing form

喜夏-厌秋 提交于 2019-12-24 05:07:02
问题 Is there a way, when creating a WinForms Custom Control/User Control, to get a reference at runtime to the form the control is placed on, so as to access various properties of that form? I would rather not pass a reference to the form into the constructor of the control, as, for various reasons, I need to keep a default constructor with no parameters. One example: I have several Custom Controls that encapsulate Win32 API calls, and some of the calls require Window handles to be passed as