|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Change look of button..net 2003
I have a form with 1 button and several labels on it. I don't want the button to be the default if enter is pressed. I want the user to have to actually click it for it to work. I also don't want it to have that "selected" look with the dotted line around the text. What can I do about all this? Thanks. Off the top of my head, during form load event you can explicitly set
focus to a different control, this will take care of the selected look and stop the unwanted default behavior as well. Show quoteHide quote "cj" <cj@nospam.nospam> wrote in message news:Oua#Kry2GHA.1068@TK2MSFTNGP05.phx.gbl: > .net 2003 > > I have a form with 1 button and several labels on it. I don't want the > button to be the default if enter is pressed. I want the user to have > to actually click it for it to work. I also don't want it to have that > "selected" look with the dotted line around the text. What can I do > about all this? Thanks. -- Cheers, Robert Porter Curiously I could not get label1.focus in the form load event to fix the
problem. It seemed to have no effect at all. Why???? Keep in mind the only other controls on the form are labels so I was setting focus to label1. But label1.focus in the button1.click event works. After button1 click event runs the button loses focus just like I want it to. Moving on I found setting the tabstop property of button1 to false made the button come up unselected when the program starts. So between adding label1.focus in button1.click and setting the tabstop property of button1 to false I guess my problem is solved. But I would like to know if there was another way I should have done this and why setting label1.focus in the form load event didn't work. If anyone has any ideas???? Robert Porter wrote: Show quoteHide quote > Off the top of my head, during form load event you can explicitly set > focus to a different control, this will take care of the selected look > and stop the unwanted default behavior as well. > > > > "cj" <cj@nospam.nospam> wrote in message > news:Oua#Kry2GHA.1068@TK2MSFTNGP05.phx.gbl: > >> .net 2003 >> >> I have a form with 1 button and several labels on it. I don't want the >> button to be the default if enter is pressed. I want the user to have >> to actually click it for it to work. I also don't want it to have that >> "selected" look with the dotted line around the text. What can I do >> about all this? Thanks. > > > -- > Cheers, > > Robert Porter > > > To use label1.focus in the load event you must call Me.Show first. I'm
not 100% but I imagine it doesn't set the focus because the form isn't "visible" (for lack of a better word) yet. Alternatively, if using .NET 2.0, you could place the code is the Shown event. Thanks, Seth Rowe cj wrote: Show quoteHide quote > Curiously I could not get label1.focus in the form load event to fix the > problem. It seemed to have no effect at all. Why???? Keep in mind the > only other controls on the form are labels so I was setting focus to > label1. But label1.focus in the button1.click event works. After > button1 click event runs the button loses focus just like I want it to. > > Moving on I found setting the tabstop property of button1 to false made > the button come up unselected when the program starts. So between > adding label1.focus in button1.click and setting the tabstop property of > button1 to false I guess my problem is solved. > > But I would like to know if there was another way I should have done > this and why setting label1.focus in the form load event didn't work. > If anyone has any ideas???? > > > Robert Porter wrote: > > Off the top of my head, during form load event you can explicitly set > > focus to a different control, this will take care of the selected look > > and stop the unwanted default behavior as well. > > > > > > > > "cj" <cj@nospam.nospam> wrote in message > > news:Oua#Kry2GHA.1068@TK2MSFTNGP05.phx.gbl: > > > >> .net 2003 > >> > >> I have a form with 1 button and several labels on it. I don't want the > >> button to be the default if enter is pressed. I want the user to have > >> to actually click it for it to work. I also don't want it to have that > >> "selected" look with the dotted line around the text. What can I do > >> about all this? Thanks. > > > > > > -- > > Cheers, > > > > Robert Porter > > > > > > Hi cj,
I agree with Seth, because when the Form.Load event fires, the form hasn't been visible. However, the Focus method requires the parent control to be visible and enabled. That's why the focus method doesn't work in Form.Load. Please check the following link for more information. http://msdn2.microsoft.com/en-us/library/system.windows.forms.control.focus. aspx Kevin Yu Microsoft Online Community Support ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications. Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ================================================== (This posting is provided "AS IS", with no warranties, and confers no rights.) Thank you Seth and Kevin. Makes perfect sense. Thank you.
Kevin Yu [MSFT] wrote: Show quoteHide quote > Hi cj, > > I agree with Seth, because when the Form.Load event fires, the form hasn't > been visible. However, the Focus method requires the parent control to be > visible and enabled. That's why the focus method doesn't work in Form.Load. > Please check the following link for more information. > > http://msdn2.microsoft.com/en-us/library/system.windows.forms.control.focus. > aspx > > Kevin Yu > Microsoft Online Community Support > > ================================================== > Get notification to my posts through email? Please refer to > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif > ications. > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues > where an initial response from the community or a Microsoft Support > Engineer within 1 business day is acceptable. Please note that each follow > up response may take approximately 2 business days as the support > professional working with you may need further investigation to reach the > most efficient resolution. The offering is not appropriate for situations > that require urgent, real-time or phone-based interactions or complex > project analysis and dump analysis issues. Issues of this nature are best > handled working with a dedicated Microsoft Support Engineer by contacting > Microsoft Customer Support Services (CSS) at > http://msdn.microsoft.com/subscriptions/support/default.aspx. > ================================================== > > (This posting is provided "AS IS", with no warranties, and confers no > rights.) >
Newbee - Project with single module.
force cast of object to mytype... (newbie-VB2005 EE) - filenames in ListBox Method Address from MethodInfo: How do I get it? Threading Service not going to 'Started' No "MS .NET Framework 1.1 Wizards" How can I control positioning of child windows in an MDI form? MDI Form Position Error BC30002 XXXXX Is not defined |
|||||||||||||||||||||||