|
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);
}
public string Text {
get { return textBox1.Text; }
set { textBox1.Text = value; }
}
private void textBox1_TextChanged(object sender, EventArgs e) {
if (TextChanged != null)
TextChanged();
}
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.
|
|
|
|
|
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...!!
|
|
|
|
|
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')
|
|
|
|
|
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.
|
|
|
|
|
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
|
|
|
|
|
hey all
with the help of eduard's response for my previuos message "windows service installation" i have installed my application and service both, but when i start my service it is giving following message and stops
"the service on local computer started and stopped. Some services stop automatically if they have no work to do for example the performance logs and alert services"
can u help me with this
thanks for responses
regards
narendra singh
|
|
|
|
|
The message is self explanatory, your service is starting, finishing processing whatever you told it to, and then stopping.
What is the service supposed to be doing that would keep it running?
|
|
|
|
|
yes scott i m agree with u but it is not performing the actions defined within onstart(), service have to send a message and then it should be stop
|
|
|
|
|
Where is it sending a message? Is it connecting to a server socket and sending a message or what?
|
|
|
|
|
actually it is sending a e-mail message to wish happy birthday
by taking the dob from the database
|
|
|
|
|
Then it is probably sending the e-mail and failing but it is not notifying you that it failed.
Try running the code in a normal application and see if the e-mail is sent.
What account are you running the service under?
|
|
|
|
|
actually i m using single database in both application as well as service. but sql server is not allowing to access the database which is already in use, it is generating a error which says .mdf file is already in use, i m running service under local system
thanks for ur response
|
|
|
|
|
If it is giving the error that the mdf file is already in use then it is probably a MS Access database and you probably have the database open in access or you did not close the connection properly and the database is still locked. Is there an ldb file in the same directory?
|
|
|
|
|
ok let me explain
i m creating a application in which i want a functionality of wishing happy birthday automatically to the customers by sending email by taking there dob from the customer table which is in sql server 2005 database, so i added a windows service project in same solution and done all the coading in onstart(), i also created a setup which install both application and service on the local system, after installing when i try to start the service then problem occurs, i provided connection string for the database also, can we use single database in different projects in same solution, i think now the problem is clear to you.
waiting for ur response
thanks
|
|
|
|
|
If it is an MS Access database you could have problems accessing it from multiple projects simultaneously depending on how you connect to the database.
I think that instead of using a Windows service you should just build a simple console application that runs once a day from task scheduler.
|
|
|
|
|
hey scott
thanks for ur all replys, now i have added this functionality in application itself, with the help of functions, which checks the date from database and send mail automatically to the contact.
thanks for ur responses
regards
narendra singh
|
|
|
|
|
NarendraSinghJTV wrote: done all the coading in onstart(),
Well don't. OnStart is just for that. Move your code and try debugging by connecting to your service from the ide - and you cannot debug the OnStart code. Also try logging errors soemwhere (say a file) so you can see whats going wrong.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
thanks bob for ur valuable response
thanks for all the responses
regards
narendra singh
|
|
|
|
|
Debug your services. It throwing some exception at runtime ! That's why you are getting this message.
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
yes abhijit u r absolutely right it is throwing an exception
actually i m using single database in both application as well as service. but sql server is not allowing to access the database which is already in use, it is generating a error which says .mdf file is already in use
thanks for ur response
|
|
|
|
|
Hi,
I would like to know, when I click a button, whcih other events are called before button click event is called.
thank you,
|
|
|
|
|
You can write a small program which subscribes to button events and shows an event on the screen
|
|
|
|
|
Are you talking about Windows Form or Web Form ?
|
|
|
|