Custom Window Control
-
Hi All, I want to design a custom window control which can be derived from textbox and to which i can add another control like month calendar or keyboard panel. I have tried user control for this but then i can't derive this from textbox and if i design a custom control that derives from textbox class then how i can add keyboard panel/ month calendar to it? If i have to design a web control instead of window control then i can add controls to inherited textbox control via rendering the required html. but how this task can be done in window control? [Addition]The idea in my mind is design it like user control and then expose the required properties/ event through the custom control. Is it a right solution? or is there a better solution for this problem?[/Addition]
-
Hi All, I want to design a custom window control which can be derived from textbox and to which i can add another control like month calendar or keyboard panel. I have tried user control for this but then i can't derive this from textbox and if i design a custom control that derives from textbox class then how i can add keyboard panel/ month calendar to it? If i have to design a web control instead of window control then i can add controls to inherited textbox control via rendering the required html. but how this task can be done in window control? [Addition]The idea in my mind is design it like user control and then expose the required properties/ event through the custom control. Is it a right solution? or is there a better solution for this problem?[/Addition]
Why are placing all that inside a TextBox? Maybe if you can tell the purpose of having such control, one can respons in a better way. You can create a user control that will have a TextBox, and a Keyboard panel and a month calendar.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
-
Hi All, I want to design a custom window control which can be derived from textbox and to which i can add another control like month calendar or keyboard panel. I have tried user control for this but then i can't derive this from textbox and if i design a custom control that derives from textbox class then how i can add keyboard panel/ month calendar to it? If i have to design a web control instead of window control then i can add controls to inherited textbox control via rendering the required html. but how this task can be done in window control? [Addition]The idea in my mind is design it like user control and then expose the required properties/ event through the custom control. Is it a right solution? or is there a better solution for this problem?[/Addition]
It is posible to add extra control to a textbox by inheritance, but it is not simple. A drop down control can be added by dynamically displaying the dropdown control positioned relative to the textbox in it's parent at runtime in appripriate event eg. the right mouse click. However most often you would want a User control to do this. It is much easier. Out of interest, why would you want a keyboard drop down on a windows app? Or are you developing for Windows mobile? Sorry, even then it does not make sense to me. And a calendar drop down only makes sense on a date picker which already has one. What is it that you really want to add to the textbox?
If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850) www.JacksonSoft.co.uk
-
Hi All, I want to design a custom window control which can be derived from textbox and to which i can add another control like month calendar or keyboard panel. I have tried user control for this but then i can't derive this from textbox and if i design a custom control that derives from textbox class then how i can add keyboard panel/ month calendar to it? If i have to design a web control instead of window control then i can add controls to inherited textbox control via rendering the required html. but how this task can be done in window control? [Addition]The idea in my mind is design it like user control and then expose the required properties/ event through the custom control. Is it a right solution? or is there a better solution for this problem?[/Addition]
Create a UserControl and add the constituent controls in it, for example, text box, month calendar, etc. Expose the properties, events and methods of the constituent controls by creating properties, events and methods for the UserControl and mapping them to the constituent controls. For example:
class MyTextBox {
TextBox textBox1 = new TextBox();
EventHandler TextChanged;public MyTextBox() { textBox1.TextChanged += EventHandler(textBox1\_TextChanged); } //Expose property public string Text { get { return textBox1.Text; } set { textBox1.Text = value; } } //Expose event private void textBox1\_TextChanged(object sender, EventArgs e) { if (TextChanged != null) TextChanged(); } //Expose method public void Clear() { textBox1.Clear(); }
}
Custom controls can only be used to extend the functionality of an existing control. You cannot add additional controls to it.
-
Hi All, I want to design a custom window control which can be derived from textbox and to which i can add another control like month calendar or keyboard panel. I have tried user control for this but then i can't derive this from textbox and if i design a custom control that derives from textbox class then how i can add keyboard panel/ month calendar to it? If i have to design a web control instead of window control then i can add controls to inherited textbox control via rendering the required html. but how this task can be done in window control? [Addition]The idea in my mind is design it like user control and then expose the required properties/ event through the custom control. Is it a right solution? or is there a better solution for this problem?[/Addition]
Thanks to all for taking intrest in my problem. Now i just understood that i am making some mistake. When i searched CP more, i got this article A Touch Screen Keyboard Control in WPF[^]. It was my exact requirement but i have to design a window control not WPF. Now i got the idea from this article that i should display the keyboard panel as another window not to include panel in the control itself.
-
Thanks to all for taking intrest in my problem. Now i just understood that i am making some mistake. When i searched CP more, i got this article A Touch Screen Keyboard Control in WPF[^]. It was my exact requirement but i have to design a window control not WPF. Now i got the idea from this article that i should display the keyboard panel as another window not to include panel in the control itself.
If you really need a new window for the keyboard, fine. Or else you can create a user control with SplitPanel where one panel will have the textbox and other would have the keyboard.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
-
Thanks to all for taking intrest in my problem. Now i just understood that i am making some mistake. When i searched CP more, i got this article A Touch Screen Keyboard Control in WPF[^]. It was my exact requirement but i have to design a window control not WPF. Now i got the idea from this article that i should display the keyboard panel as another window not to include panel in the control itself.
Touch screen. now it all makes more sense.
If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850) www.JacksonSoft.co.uk
-
If you really need a new window for the keyboard, fine. Or else you can create a user control with SplitPanel where one panel will have the textbox and other would have the keyboard.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
but then my problem remains same that i won't be able to inherit this control with TextBox so that all it's properties and events are avialable to the Control User. So now if there is any idea for this problem then i'll be really thankful to you.
-
but then my problem remains same that i won't be able to inherit this control with TextBox so that all it's properties and events are avialable to the Control User. So now if there is any idea for this problem then i'll be really thankful to you.
If you have a user control containing (say) a TextBox, you can make the required properties of the textbox visible by implementing them in the UserControl. Usually you wouldn't want the user of your control to have complete access to the textbox's properties - but certain properties can be exposed as you need...
public TxtBoxText
{
get {return textBox1.Text;}
set {textBox1.Text = value;)
}and so on. So users of your control can use
myUserControl1.TxtBoxText = "WhateverIWantToSetItTo";
___________________________________________ .\\axxx (That's an 'M')
-
If you have a user control containing (say) a TextBox, you can make the required properties of the textbox visible by implementing them in the UserControl. Usually you wouldn't want the user of your control to have complete access to the textbox's properties - but certain properties can be exposed as you need...
public TxtBoxText
{
get {return textBox1.Text;}
set {textBox1.Text = value;)
}and so on. So users of your control can use
myUserControl1.TxtBoxText = "WhateverIWantToSetItTo";
___________________________________________ .\\axxx (That's an 'M')
Thats what i am thinking from starting but i was not sure that this is the only solution or it's a good approach. Thanks to you all.