Click here to Skip to main content
15,891,513 members
Everything / Custom controls

Custom controls

custom-controls

Great Reads

by Martin Mitáš
How to support scrolling within your controls.
by Dejan Mauer
Free and easy way to access a web camera by using the Aforge library.
by HateCoding
A tiny custom list control
by Niemand25
A simple way to place any ObjectListView inside a ComboBox

Latest Articles

by Vassili Kravtchenko-Berejnoi
A generic workaround for auto-generating multiple custom columns in a WPF DataGrid in case where the data class has multiple properties of the same type
by Martin Mitáš
How to support scrolling within your controls.
by David Fine
Using Attached DependencyProperty to prevent closing of Popup embedded in ToggleButton
by Niemand25
A simple way to place any ObjectListView inside a ComboBox

All Articles

Sort by Title

Custom controls 

8 Jan 2012 by agent154
I'm working on hacking a custom control I found online, and I'd like to add design-time functionality to it such that a small icon appears in the top left to make it easier to move the control. Right now, there are times when moving the control just doesn't work because the mouse cursor doesn't...
8 Jan 2012 by Sergey Alexandrovich Kryukov
agent154 wrote:—mouse cursor doesn't seem to want to grab onto it properly. This is called personification, one of the kinds of trope, please see http://en.wikipedia.org/wiki/Trope_%28linguistics%29[^]. (By some reason, this very kind of trope is missing from English Wikipedia page, but it...
14 Oct 2014 by Doughnatch
Is it normal for these codes to be in the main project after class library has been placed on the form? Here: Private Sub InitializeComponent() Dim resources As System.ComponentModel.ComponentResourceManager = New...
14 Oct 2014 by OriginalGriff
It should be in the designer source files, unless you have moved the InitilizeComponent method into your own code - that is (as Richard says) standard framework initialization code which is normally in the "MyForm.designer.vb" file - except in very early versions of VS for .NET (IIRC) which...
29 Jun 2010 by AugustinJ
Hi.I want to make a custom DataGridViewCell like a DataGridViewNumericUpDownCellI have the following classes:public class DataGridViewNumericUpDownColumn : DataGridViewTextBoxColumn{ //...}public class DataGridViewNumericUpDownCell : DataGridViewTextBoxCell{ ...
29 Jun 2010 by AugustinJ
FOUND IT!!public override void PositionEditingControl(bool setLocation, bool setSize, System.Drawing.Rectangle cellBounds, System.Drawing.Rectangle cellClip, DataGridViewCellStyle cellStyle, bool singleVerticalBorderAdded, bool singleHorizontalBorderAdded, bool isFirstDisplayedColumn, bool...
10 Oct 2016 by Vincent Maverick Durano
In this post, you will learn about the Customized MessageBox, ConfirmBox and FrameBox Controls for ASP.NET WebForms and how to use them in your application.
25 Jul 2014 by JamesHurst
Walks through the creation of an on-screen virtual keyboard for entering non-ASCII chars
8 Aug 2011 by isaks
A custom panel for rows of label-control pairs useful in, for example, preferences screens.
8 Feb 2016 by DonWikki
Hello mates,I have a huge problem and hope you are kind enough to help me out :)So, I need a control which allows Drag&Drop custom controls, zooming and panning (like extending a canvas without limitations) I´ve looked around and found this nice article:A WPF Custom Control for...
8 Feb 2016 by Kevin Marois
Take a look at this[^].It shows how to do DragDrop and Zoom.
9 Sep 2011 by Magnus Gudmundsson
A WPF DateTimePicker that Works like the one in Winforms
26 Feb 2011 by MRAKAR
Hi,i'm making my own user control and have 2 questions1. i want to add a button on default properties list and i want to open a modal form when that button is clicked,2. i want to group my control properties in one category (the attribute Category(...) doesn't work, as i found it works...
26 Feb 2011 by Sergey Alexandrovich Kryukov
This is quite possible but not easy at all; you'll to write several things to allow custom edit in the PropertyGrid. I think modal form is not a good idea as you can do much better by providing a custom in-place editor. However, a modal form is also possible: you in-line editor will be the...
26 Feb 2011 by Henry Minute
To achieve your aims you will probably have to write a UITypeEditor[^] and one or more ControlDesigners or one of its descendants and quite possibly one or more TypeConverters. From your description possibly an ExpandableObjectConverter[^].Here is a link to an example that uses most of these.[^]
27 Feb 2011 by MRAKAR
I thought something about thispublic Sometype PropertyName{ get { return SomeValue; } set { (new Form()).ShowDialog(); }}
29 Jul 2012 by WebMaster
I use these codes at OnCreateControl to add DataGridViewLinkColumn.But I can't set text for column(not headerText, just text).Note: When I add column by designer there is property named Text but inside below code it is not.DataGridViewLinkCell cell = new...
1 Aug 2012 by freedeveloper
Please revise if you see in designer the columns or rows. Columns haven't text, because they have differents data in each cell (normally). I can not found "text" in the designer, you can also only give the tooltip and header text.If you want to have a default value in the column, you must...
22 Feb 2014 by agent_kruger
i am developing an application based on treeview but stuck at a point. I want to add some controls to the treeview such as textbox and picturebox where the nodes are displayed. But i don't know how to replace tree nodes with (textbox and picturebox).Can somebody help me here?Thanks in...
22 Feb 2014 by Ravi Bhavnani
See this[^] CodeProject article for a starting point on how to do this. This example demonstrates how to add a ComboBox to a node, which you can extend to other types of controls./ravi
1 Jan 2015 by Malayali Coder
I am trying to create a custom control with multi select option. what i want is a dropdownlist whose contents all have text boxes to enable multiple selection. what i have done till now is i used a text box and image button to show as dropdownlist. And on clicking it, a panel will be opened...
2 Jan 2015 by Tejas Vaishnav
There will be a custom dropdown control with checkbox is available on CodePlex with source code, you can review it and make appropriate changes accordingly to your control, or you can use that directly instead of building your own...
21 Nov 2012 by MRS1989
I've created my custom control. It has a property that is called "Tab." This property adds a collection of "FloorsInformation" controls that are inherited from "DockContainerItem" class to my custom control.Figure 1[^]Now, I want to add "FloorsInformation" controls to my custom control after...
1 Apr 2010 by zhonglin.liang
There are many buttons in a dialog. Add thick rectangle border around the button after it is pressed and hide thick rectangle border after the button is pressed again. After I pressed many buttons ,the buttons that is pressed are of thick rectangle border until I pressed them again. How to...
2 Apr 2010 by Gary Stafford
If you are asking this in regards to web-based solution, then using jQuery would make this fairly easy by switching the button's CSS classes.
27 Sep 2018 by teolazza
I, I've created a component with a collection of controls as property:[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public List ControlsToNotTranslateThen I've created an UserControl, added some controls to it: buttons and labels.Now I...
27 Sep 2018 by Gdno
Please see if this helps you in some way, see that in the "TargetControls" property of the control that is in form1 you can select the controls of the same type, to appear all the controls is just to change the control code, where is ExampleControl you changes to Control. Link to demo:...
16 Jan 2011 by Madhusudan Nagaraja
Hi, This is my first question in the forum.Requirement : I am supposed to create a custom text box control which has properties such as Numeric, Alphabetic, AlphaNumeric.Suppose Numeric property is set .. user should be able to enter only Numbers in text box, Similarly the functionality...
16 Jan 2011 by Sergey Alexandrovich Kryukov
If this is ASP.NET you really need to filter events in the client part (in the Web browser). Please see the Answer by Jason C Daniels who provided very clear motivation.I already answered similar question (cannot find it...). With Javascript, you can filter out characters not allowed in the...
16 Jan 2011 by Jason C Daniels
In order to process key-strokes in a webpage, you MUST write some javascript. With that said, you *could* call into the codebehind in the javascript handler for the keypress... but it will be horribly inefficient.Why? Because you will cause network traffic, and therefore a very noticable...
20 Jul 2013 by sharadtripathi204
I had requirement that editor should have only Bold, Italic, Underline tools, so I customized Html editor of ajaxcontroltoolkit by inheriting AjaxControlToolkit.HTMLEditor.Editor class. It works fine but It returns old content after first time. e.g. I browse the page and write - "ABCD" in...
9 Jan 2013 by WebMaster
Customize EditText in Android with has lines inside.
18 Jul 2012 by MAU787
Hi all..We can make and use custom controls in asp.net.While creating custom control can we include windows control and its functionality in it?means if i want to use windows picturebox in web browser can i create it with custom control and use it?i have tried it with windows control...
18 Jul 2012 by Christian Graus
No, of course not. Your web page may run on a lot of devices that are not windows. You should consider learning what the world wide web is and how it works. ASP.NET generates HTML only, that is all your browser understands. You can't use it to do anything that you can't do with HTML.
15 Oct 2015 by MVK_VIJI
what is the mathematical formula for arrange several UI Element in circular shape???
16 Oct 2015 by phil.o
You may have a look at Trigonometric Functions[^].
18 Oct 2015 by MVK_VIJI
protected override Size ArrangeOverride(Size arrangeBounds) { Point currentPosition = new Point(OuterRadius, InnerRadius); int countChild = Children.Count - 1, i, j = 2, count = 0; double angle = 2 * Math.PI / 7, k = 0; double...
15 May 2011 by Sachin Gokhale
Hello Everyone, I am new to Silverlight 4.0. I am creating a custom control using Telerik RadGridView for Silverlight. My aim is to do all the generic handling like formatting of cells, text alignment and so on, in the custom control. I don't want any end developer to code for such generic...
17 Aug 2011 by Member 3071075
I have created a custom control that inherits from the Panel control. I did this to add a click event to it. The custom control is contained inside a ListView so I am trying to add a property that I can bind data to and retrieve on the click event.Here is the markup:
6 Mar 2024 by Graeme_Grant
List is not a bindable collection. You need to use the ObservableCollection Class (System.Collections.ObjectModel) | Microsoft Learn[^]. Here is a working solution for a similar question. Create a new project and add this code: 1. Classes: ...
6 Mar 2024 by hardover
Binding not working when Custom Control is used in a DataGridTemplateColumn My charge is to provide a control that can be used to select multiple items from a list of items. The items are classification tags. The object is a Tag. It has three...
12 Mar 2024 by hardover
With guidance from others, I have solved the problem. The key was to use the PropertyChangedCallBack to manage when the SelectTags List was bound. In summary, the solution involves capturing the point at which the actual List binding takes...
10 Jul 2011 by XtErMiNaToR102
Hi all,I have a list of custom DataGridViewColumns that each have a bool field called "Static" to indicate if it should be used during "quick filter" in my user control. My aim is to present a list of all the custom columns with their "Static" values to the user/designer on the forms...
12 May 2010 by OmiAshish
i want to build a ComboBox Custom Control. in which after selection or entry its detail portion to be display in Datagridview so that user can select with grid with detail information. and after selection datagridview visibility get false.The Problem is that in Custom Control the value...
12 May 2010 by Christian Graus
Fix your code. What else can we say ? Did you consider posting your code so we can see your mistakes ?
18 Apr 2011 by ivan spams
hi therei'm building a c# wpf multi-touch application which consists of multiple objects on the screen which can be manipulated using touch. these "information objects" will display various types of information such as text, webpages, images, video.presently i have my objects defined in...
28 Apr 2011 by Renat Khabibulin
you wrote:"i gather that i need to extend some visual element (probably UIElement?) but i cant change the CustomControl1 class from extending Control"Control is inherited from FrameworkElement which is inherited from UIElement :)As I understand you want to create reusable CustomControl...
29 Oct 2013 by Mada Naga Sankar
Hello, I am developing a custom usercontrol. I have a button in that control. I assigned a event for that button. After registering the control with aspx page i am able to see that event in event list of that control. But onclick of that button event is not firing. Below is the code i...
1 Jul 2015 by Zaid Pirwani
SHORT DESCRIPTION: Am interested in how to implement basic snapping functionality among drag/drop-able custom controls in C#, where to start and can anyone give any pointers to something similar etc.For simplicity, assume Button Control, I have a ToolBox of Buttons in my App, User drags and...
1 Jul 2015 by Richard MacCutchan
See https://www.google.com/search?q=drag%20drop%20c%23[^]. Google is always the first place to search for general information.
3 Jun 2021 by thrainder
Hi, I am trying to create a small Winform with some round edges (all 4 corners). I got some code from the internet But, the above code is not working as expected. This code only round the top upper corners and the right upper corner is...
3 Jun 2021 by OriginalGriff
If you got code from the internet, then go back there and ask them: they know their code better than we will!
3 Jun 2021 by Wendelius
CreateRoundRect isn't pixel perfect so as far as I know you won't be able to get smooth corners using only that function. An example of smooth corners can be found for example here c# - Creating Smooth Rounded Corners in WinForm Applications [^]
9 Nov 2017 by Tim8w
I have a C# CustomControl that is compiled into my project. I get the error: "Invalid Resx file. Type GradientOptions, Calculator, Version=1.0.0.0, Culture=neutral, Calculator PublicKeyToken=null in the data at line 167, position 4 cannot be located. Line 169, position 5" Lines in question are...
13 Dec 2020 by Taher El Marengoze
I am trying to learn how to make custom controls. I am trying to make a dataGridView with a Treeview Column (Cell Editing control not how the data is displayed in the cell) based on this article Here. But I can't tell my code how to take the...
13 Dec 2020 by Gerry Schmitz
You don't put a "treeview in a cell"; the best you can hope to do is link to a tree view (somewhere) based on the value in the cell. (like a BOM#). The article discusses the "Date Picker"; which "lauches" a (.NET) calendar type control; it's not...
13 Dec 2020 by BillWoodruff
See: [^] for an article on a TreeListView here. There are lots of 3rd. party controls, like DotNetBar: (commercial) [^]. Using what the ToolBox provides: consider a SplitContainer with a TreeView in Panel1, and a DataGridView in Panel2 ... or a...
24 Jan 2012 by thechazm
Hello all. I have been trying to wrap my thoughts around how to start this project I want to design and honestly I just dont understand how to get objects, or mainly my custom controls, to work together.Ok here is the example. I want to use a panel but on that panel I want connector...
24 Jan 2012 by Shahin Khorshidnia
Hello,I did almost a same thing but by WPF for a company.I made some Icons that they where connected together with lines. (Like VISIO)I've never seen any prepared user control for connector point. At leat I don't know.I built it and I think you have to build.1. Save dimensions...
26 Dec 2014 by Alexey Gapon
Hello I am developing a custom control for my GUI but now i have strange thing happening. After rebiulding the project, control`s Location property turns to (0,0).Designer changing it`s value in design mode but it sets to (0,0) everytime i rebuild the project. My Control is child of Panel...
26 Dec 2014 by Dave Kreskowiak
Your properties that you want to set from the designer code need the DesignerSerializationVisibility attribute added to them.For example: [Category("MyProject.Forms"), DefaultValue(0),Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] ...
8 Jan 2015 by Malayali Coder
I am trying to create a Multi Select dropdown list custom control inheriting from the checkboxlist control. it has a title property which will be set as the default text of the dropdown control rendered in a div tag with an image to show dropdown icon as in the code below. I also have a...
11 Jan 2015 by BacchusBeale
In your Render method you could add the title element with a specific id to reference from JavaScript using getElementById. Also for each checkbox or select control you can add an onchange event attribute that will call the required JavaScript function when the selection changes. The onchange...
17 Jan 2016 by cmbay
I am creating a WPF Custom Control Template and I would like one of the GeometryDrawing Brushs to use the Background Brush of the control's container. For example if I put this control on a Window I would like this particular Brush to use the Window's Background Brush. Like wise if the control...
18 Jan 2016 by Sergey Alexandrovich Kryukov
cmbay asked:…So the question is, is it possible to bind the Background of my control to its' container's background without explicitly identifying the container.It can be done by binding using RelativeSource. Please see:RelativeSource Class (System.Windows.Data)[^],C# Corner:...
5 Apr 2014 by User 9174741
I want to use Windows7 visual style, like in this image, in my WinApp C# projects ..so is there an easy way to do it or I have to make this by my self?http://oi57.tinypic.com/r9qv85.jpg
5 Apr 2014 by Sergey Alexandrovich Kryukov
You can find enough material on just CodeProject: http://www.codeproject.com/search.aspx?q=forms+%28skins+OR+themes+OR+skin+OR+theme%29&doctypeid=1&field=title[^].In particular:.Net Win Forms Themes[^],Using Themer To Skin Forms and Controls[^],Adding custom skins for Forms in...
5 Apr 2014 by Abhinav S
It could depend of what version of the framework you are using.It also depends on whether you are using WPF or Windows Forms.All of them are possible just that the way you implement would be different.For .Net 2.0 for e.g. try http://windowsformsaero.codeplex.com/[^].
16 May 2013 by alljinx
Hi all,I created a Custom Control and I want it as EditingControl in a DataGridView. All work fine but, I'm not able to catch the Enter Key in my Custom EditingControl.The EditingControlWantsInputKey is implemented but is never called when I press the Enter key. The others keys (as Up...
17 May 2013 by Mayur Panchal
I think u should handle OnPreviewKeydown event to catch 'Enter' key in user control and write your stuff there.
5 Feb 2010 by Member 645156
I have a WPF Custom Control inherited from Button.How do I programatically get the custom control to capture the Click Event (so that I can record the action and do some internal work)(basically I want to catch the event and set a certain property to a certain value) and make this part of...
5 Feb 2010 by Member 645156
SolvedI have realised why I had a problem.I could not see the Click eventThis was because I was not explicit enought in my class declaration:I put public class StateButton : Buttonobviously picked the wrong button public class StateButton :...
25 Jan 2012 by thechazm
I am trying to draw a rectangle on another rectangle on the bottom center of the parent rectangle. I am using some very basic code that I thought would work but it does not display the child rectangle at all I called bottomconnector. Below is some of my code"[Browsable(false)]public...
25 Jan 2012 by Tim Groven
Try this:return new Rectangle((this.ClientRectangle.Width / 2) - 15, this.ClientRectangle.Bottom - 30, 30, 30)They way you were doing it, the top of the new rectangle starts at the exact bottom of the first one, so when it draw, it goes below the bottom of the first, making it so you...
15 Nov 2015 by ChrisCreateBoss
I'm working in an audio player based on C#The player component I use is made with the CSCore open-source library.I have a circular slider control which has a ProgressValue property based in an Integer. When I play a song, the slider's max value is set to the song's totalSeconds length,...
15 Nov 2015 by George Jonsson
First of all you could probably get a better answer here https://github.com/filoe/cscore/issues[^]When it comes to your code snippet you can simplify like thisprivate void songProgress_ValueChanged(object sender, ValueChangedEventArgs e){ player.Position =...
4 Nov 2012 by MRS1989
I add my created custom control to the new Windows Form and add some Tab to it by "Tabs" property. However, when I delete my custom control from Windows Form, elements of "Tabs" property are not removed. Please see below figures for more information:Figure 1[^]Figure 1 - My custom control...
6 Nov 2012 by MRS1989
I found the solution. For remove "Tabs" property members automatically after deletion of custom control from its Parent control (Windows Form), must apply some changes to "Dispose" method of the "FloorsGrouping" class that inherited from "Bar" class. Please see following line of codes that must...
23 May 2012 by Ranopi
Hi everyone.I'm trying to create a custom comtrol much similar to a combobox,but wich display a listview instead of a listbox, where you can add/show columns and items as you would in a regular listview control.The one problem i'm finding is that after i add the custom control to a form...
23 May 2012 by VJ Reddy
For the properties of the object set at design to be persisted in the form the DesignerSerializationVisibilityAttribute with the argument DesignerSerializationVisibility.Content is to be used like _Public ReadOnly...
25 Jan 2012 by thechazm
Thank you all so much for helping me so far. I have another question if you wouldn't mind.The goal I am trying to achive is have one custom control that is a rectangle shape and I would like to add connectors to it as a seperate control so it can overlap the edge of the first rectangle...
25 Jan 2012 by Sergey Alexandrovich Kryukov
My advice is: don't do it this way. This is possible in principle; I knew few attempts, all pretty much unsuccessful; and it's clear why.I explained what to do in my past solution: Drawing Lines between mdi child forms[^].The question is not exactly the same as yours, but the right...
25 Jan 2012 by Espen Harlinn
I think you are looking for something like this:WPF Diagram Designer - Part 1[^]WPF Diagram Designer - Part 2[^]WPF Diagram Designer - Part 3[^]WPF Diagram Designer - Part 4[^]The articles are well written and the concepts fundamental to WPF designer integration, but if you are new...
25 Jan 2012 by Sergey Alexandrovich Kryukov
Now, lets turn to WPF and let me give you some further ideas before we close this discussion and you continue on your own. I hope you will choose to accept this one formally, too. (You can click green "Accept" button on more than one.)With WPF, you can put all your diagram elements on the...
4 Oct 2016 by BlackMaxiAUT
Hi cracks,i wrote a WPF custom control libary. So when using them in a test application everything is fine. Im developing an addin for a Win32 application. When using my custom controls in an WPF element host. The WPF UserControl throws an XAML.Parse Exception "FileNotFound".So my...
4 Oct 2016 by johannesnestler
some time since you asked this question... - what about your deployment now? Did you get it right?Your question is a little confusing because you talk about a CustomControl - this is a special type in WPF: you derive controls with your own ControlTemplate (theme) from it - opposed to a...
14 Jun 2011 by armm1388
HiIn last versions of VS there are 2 topics: User Control and Custom Controlin VS2010 I didn’t find Custom Control but in file->new->project->webI found a ASP .Net Server Control.Is it same the "Custom Control" in last version of VS?If not ,how Can I Create a Custom Control (web...
14 Jun 2011 by Sergey Alexandrovich Kryukov
I did not find anything from older versions which disappeared from VS 2010.Unlike UserControl, Custom Control is simply a class derived from a base class Control or one of derived classes. Just write its code:public class MyControl: Control { //your code goes here}—SA
14 Jun 2011 by RaviRanjanKr
Try a well written article which will guide you how to create Custom Control in VS 2010Creating a Custom Web Server Control in ASP.NET using Visual Studio 2010[^]
18 Dec 2011 by Janaka Medawala
Im creating a simple application to search and manipulate a database.I want to add a text box to search a name but I want the textbox to be eyecandy.I dont want the traditional textbox.Instead I would like something like thishttp://i40.tinypic.com/2wcdtte.jpg[^]Can anyone please tell me how...
28 Feb 2012 by Member 8023568
HiI'm creating a custom windows form control in VS2010. I dragged and droped a toolstrip to my custom control. All I want to be able to do is make the toolstrip1.Items Editable from the designer.I gave access to the toolstrip by adding a property.public ToolStrip ToolStrip{ ...
17 Sep 2016 by hexgear
Hi all as I stared my development with android I always wanted to create a Custom view . To learn about canvas I decided to create matrix rain effect which I can add to my android layout. Here is the complete tutorial which I have post I posted it at my blog http://www.androidlearner.com/
26 Nov 2014 by Kit1624
I have an user controls which contains a datagridview. This user control inherits the datagridview. now I want to add some properities for this user control and some new events for it. How can I do that? Please, help me.
9 Aug 2011 by Oludayo Alli
Steps in creating a custom TimePicker control in WPF 4.
8 Jan 2013 by bughu
Hi!I need some help with creating a customized combobox. What I want is to create a combobox with coloured borders and arrow. Something like this:http://www.cybersky.com/images/night_vision_mode_large.png[^]I have searched all over the internet and the only thing I found was to draw...
9 Jan 2013 by Richard MacCutchan
Lots of suggestions here[^].
13 Sep 2016 by Andrey A. Eroshenko
Hello all.I have a WPF custom control placed to grid. There is some standard wpf controls placed to same grid. My custom control has a binded dependency property. Parent grid have a datatrigger on Property Visibility and triggered when DataContext is not null.Using my custom...
30 Apr 2012 by Member 3196082
I am creating a custom control which is essentially a TextBox, but also includes a label.I am mainly interested in the TextBox properties in the designer, so I am inheriting from TextBox.Public Class LabelTextBox : Inherits System.Windows.Forms.TextBox Protected m_lblLabel As...