Click here to Skip to main content
15,889,527 members
Home / Discussions / C#
   

C#

 
QuestionManaging application execution Pin
jimmov115-Feb-09 15:59
jimmov115-Feb-09 15:59 
AnswerRe: Managing application execution Pin
Luc Pattyn15-Feb-09 16:36
sitebuilderLuc Pattyn15-Feb-09 16:36 
QuestionConvert a string to Float (two numbers after the comma) Pin
abbd15-Feb-09 12:30
abbd15-Feb-09 12:30 
AnswerRe: Convert a string to Float (two numbers after the comma) [modified] Pin
Nico Patitz15-Feb-09 12:46
Nico Patitz15-Feb-09 12:46 
QuestionChild controls interaction in User Control. [modified] Pin
hdv21215-Feb-09 11:39
hdv21215-Feb-09 11:39 
AnswerRe: Child controls interaction in User Control. Pin
Nico Patitz15-Feb-09 12:16
Nico Patitz15-Feb-09 12:16 
GeneralRe: Child controls interaction in User Control. Pin
hdv21215-Feb-09 12:18
hdv21215-Feb-09 12:18 
AnswerRe: Child controls interaction in User Control. Pin
_Maxxx_15-Feb-09 14:18
professional_Maxxx_15-Feb-09 14:18 
If you want to, for example, handle the click event of a button on a usercontrol, you should be handling it in the usercontrol code - nit in the form on which ou put the user control.

Similarly,if you want to design the button, you deign it in your user control.

If you want to be able to reuse your user control with, say, a different font on the button, then you need to add a property to your user control (lets call it ButtonFont) and write the Setter and Getter to access the Button's Font property.

If you REALLY want to access the button itself outside of the user control, at runtime e.g. you want code that says

MyUserControl1.OKButton.Text = "Hello";

then you need to set the Button's 'Modifiers' property in the user control to Public - so you can access it. This is not good practice, though, better to hide the button itself, and allow access only to those properties you want to give access to.

Similarly if you want to handle the click event of the button on the user control from within your form, you need to add an event to your user control - raise the event when the button is clicked. Thus the form doesn't know it was necessarily a button click event, just that the user control is telling it that some event has occurred.

For example - if your UC is used to select from a list of items, you might allow the user t double click on an item, selec the itme th click OK,select the item and press enter, click on a linklabel - etc. etc.

By raising a single event from the user control, the 'user' of tat control doesn't need to worry about what caused the event to fire - it just needs to know that it needs to handle the event because it has been raised.

Sorry for the rambling - this is a big subject & it depends on your requirements as to what you need to do for the best.

___________________________________________
.\\axxx
(That's an 'M')

GeneralRe: Child controls interaction in User Control. Pin
hdv21215-Feb-09 21:11
hdv21215-Feb-09 21:11 
QuestionMy class Pin
Member 391685615-Feb-09 10:44
Member 391685615-Feb-09 10:44 
AnswerRe: My class Pin
DaveyM6915-Feb-09 11:24
professionalDaveyM6915-Feb-09 11:24 
AnswerRe: My class Pin
Christian Graus15-Feb-09 11:31
protectorChristian Graus15-Feb-09 11:31 
GeneralRe: My class Pin
Member 391685616-Feb-09 0:27
Member 391685616-Feb-09 0:27 
GeneralRe: My class Pin
Wes Aday16-Feb-09 4:11
professionalWes Aday16-Feb-09 4:11 
GeneralRe: My class Pin
Member 391685616-Feb-09 22:09
Member 391685616-Feb-09 22:09 
QuestionCircle creation in c# Pin
anishkannan15-Feb-09 7:36
anishkannan15-Feb-09 7:36 
AnsweryRe: Circle creation in c# Pin
DaveyM6915-Feb-09 9:01
professionalDaveyM6915-Feb-09 9:01 
GeneralRe: yRe: Circle creation in c# Pin
anishkannan15-Feb-09 17:36
anishkannan15-Feb-09 17:36 
Questionclient server architecture for web appln in C# Pin
madhuri pokharkar15-Feb-09 7:14
madhuri pokharkar15-Feb-09 7:14 
AnswerRe: client server architecture for web appln in C# Pin
DaveyM6915-Feb-09 7:40
professionalDaveyM6915-Feb-09 7:40 
AnswerRe: client server architecture for web appln in C# Pin
DaveyM6915-Feb-09 9:16
professionalDaveyM6915-Feb-09 9:16 
AnswerRe: client server architecture for web appln in C# Pin
Dave Kreskowiak15-Feb-09 10:12
mveDave Kreskowiak15-Feb-09 10:12 
Question3D Interactive Environment in C#! Is it possible? Pin
Etienne_12315-Feb-09 7:12
Etienne_12315-Feb-09 7:12 
AnswerRe: 3D Interactive Environment in C#! Is it possible? Pin
Alexander M.,15-Feb-09 7:39
Alexander M.,15-Feb-09 7:39 
GeneralRe: 3D Interactive Environment in C#! Is it possible? Pin
Etienne_12315-Feb-09 8:01
Etienne_12315-Feb-09 8:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.