|
I'm developing Windows Applications under Visual Studio 2005. I've noticed that when radio buttons, check boxes or command buttons have the focus on a form, all I need to do is press the letter assigned as a shortcut key for another control for that other control to receive the focus. I really do not want that behavior, I want the user to always have to press Alt-letter for a control with a shortcut key to get the focus (when a text box has the focus, the user does have to press Alt-letter for focus to change to another control). Can anyone tell me what I need to do to ensure that the user has to press Alt-letter to set focus to a new control when a radio button, check box or command button has the focus?
Thank you...
|
|
|
|
|
use the & sign for the letter (in the text of that control) you want to use as a shortcut, and it will work with the Alt key. e.g
btn1.Text = "&button"
so the shortcut for btn1 will be 'Alt+b'
regards
sAqIb
"Our scientific power has outrun our spiritual power. We have guided missiles and misguided men."
Dr. Martin Luther King Jr.
|
|
|
|
|
I'm afraid I either posted my original question very poorly, or you misunderstood. I know how to create a shortcut key, my problem is that when a control other than a text box control has the focus, the user does not have to press the Alt key to go to another control that has a shortcut (or accelerator) key. For example, assume the command buttons below where btn1 has the shortcut set to "b", and btn2 has the shortcut set to "u"
btn1.Text = "&button1"
btn2.Text = "b&utton2"
If btn2 currently has the focus, the user only has to press the letter "b" for btn1 to get the focus. I would prefer if the user always had to press the "Alt" key before any shortcut is activated but as long as the focus is not on a textbox, the "Alt" keys is apparently now unnecessary.
I know I can tackle this issue by ensuring the Alt key is pressed in the KeyDown event of non-textbox controls, but I'm hoping there is some global setting in Tools-Options that I do not know about that will quickly tackle this issue for any apps I may develop.
Thank you...
|
|
|
|
|
hi,
how can i get the current logged in user (on the computer) from the active directory.
Best regards
jamil abou khalil
|
|
|
|
|
using System.Security.Principal;
WindowsPrincipal wp = new WindowsPrincipal(WindowsIdentity.GetCurrent());
Console.WriteLine(wp.Identity.Name);
|
|
|
|
|
Here's another method:
string user = System.Environment.UserName;<br />
Console.WriteLine(user);
Ashish
|
|
|
|
|
I am trying to get the the btnEat button to be able to access the methods for the dog object I have created but it does not exist outside of the btnCreate event. Please advise, I think its something fundamental but I can not find anywhere which answers my question, or I do not know the correct terminology for it, thanks.
************************ EVENTS on button ************************
private void btnCreate_Click(object sender, EventArgs e)
{
Animal dog = new Animal();
dog.Name = txtName.Text;
lstAnimals.Items.Add(dog.Name);
lblAnimalCount.Text = "Animal Count " + Animal.Animals.ToString();
MessageBox.Show("There is currently " + Animal.foodstock.ToString() + " units of food left");
dog.eat(); //Dog Can eat here
MessageBox.Show(dog.Name + " has eaten 1 unit of food, there are now " + Animal.foodstock.ToString() + " units left");
}
private void btnEat_Click(object sender, EventArgs e)
{
// I want to make dog eat here but not sure how.
}
************************ ANIMAL CLASS ************************
class Animal
{
public Animal()
{
Animals += 1;
}
public static int foodstock = 15;
public static int Animals;
string AnimalsName;
public string Name
{
set
{
AnimalsName = value;
}
get
{
return AnimalsName;
}
}
public void eat()
{
foodstock -= 1;
}
}
******************************************************************
Thanks a million, this is a real stumbling block for me at the moment in learning
|
|
|
|
|
i think u should define Animal dog; otside the event and in event section
private void btnCreate_Click(object sender, EventArgs e)
{
dog = new Animal();
dog.Name = txtName.Text;
lstAnimals.Items.Add(dog.Name);
lblAnimalCount.Text = "Animal Count " + Animal.Animals.ToString();
MessageBox.Show("There is currently " + Animal.foodstock.ToString() + " units of food left");
MessageBox.Show(dog.Name + " has eaten 1 unit of food, there are now " + Animal.foodstock.ToString() + " units left");
}
private void btnEat_Click(object sender, EventArgs e)
{
if(dog!=null)
{
dog.eat();
}
}
rahul
|
|
|
|
|
I have declared the object here and it works as I hoped:
namespace WindowsApplication1
{
public partial class frmAnimal : Form
{
public frmAnimal()
{
InitializeComponent();
}
Animal dog = new Animal();
....
}
Is this an acceptable place to put it or is there a standard? Do you have any advice on where I can learn about this syntax? Thanks
*-Edit-*
I also would like to add another animal, i.e a cat would I need to declare where I have put "Animal dog = new Animal();" another one for cat or could I use a variable instead of 'dog' and dynamically name the object (I really hope this makes sense!!)
Phill
|
|
|
|
|
that all depends upon ur need that what scope of accessibilty u want to provide to particular object or member,u can find it in any basic book on c#.
rahul
|
|
|
|
|
Your problem is scope. You created the object in create_click, thus it goes out of scope when the method terminates. You can create a member of the application of type Animal. Then instantiate the object in the create click. The object will have a global scope within the current form.
|
|
|
|
|
Thank you for this, I will give it a go tonight
All the best
Phill
|
|
|
|
|
Hi, I have tried to understand by what you meant by "You can create a member of the application of type Animal", please excuse me if it is a really simple thing you have suggested.
Is it possible to explain in a little more detail?
Very Much Appreciated
Phill
|
|
|
|
|
namespace WindowsApplication1
{
public partial class frmAnimal : Form
{
public frmAnimal()
{
InitializeComponent();
}
...
private Animal myAnimal;
public Animal MyAnimal
{
get{ return myAnimal; }
set{ myAnimal = value }
}
}
}
Then in your form's create method, just create the instance.
MyAnimal = new Animal;
Then it will be accessible to the entire form.
|
|
|
|
|
Thankyou for your example it has helped me a lot,
I have been practicing different examples of how to create the methods just using the console instead of jumping straight into forms and I am finding it easier to grasp the concepts
Thanks
Phill
|
|
|
|
|
Hi,
I've created a custom text control, and when i set the BorderStyle to Fixed3d, as you'd expect I get a 3d border. Trouble is, with the XP theme on, other text boxes have a flat blue border when set to fixed3d, which is what I want mine to mimic.
I've looked at the extended styles on a normal text box, and it's got WS_EX_CLIENTEDGE set, which is the same as my custom text box.
does anyone know how to get this border behaviour.
Cheers
Simon
|
|
|
|
|
Hi,
I just picked up a special interest in C# and the .NET, but having problems selecting a text for study. Can anyone with much experience advise as to the best and most comprehensive book to use for C# and the .NET for individuals with little or no programming experience?
I'm also into PHP and MySQL. I heard that the Visual Studio.Net/Visual Studio support the development of PHP codes. Is this true?
|
|
|
|
|
Wrox is very good and complete, but very boring as well...
The microsoft books weren't bad for beginners and are less boring, but they don't go in dept at all...
hope this helps...
|
|
|
|
|
The APress books are pretty good as well.
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
You won't find a book that's both good for programmers with little or no programming experience and comprehensive.
However, the Micrsoft Press books for the Visual Studio Express editions might be worth a look.
Kevin
|
|
|
|
|
|
Wrox has a series of books that start at the beginner level, and show a "road map" of books to help you progress in your task.
|
|
|
|
|
How can I detect the sound device?
Which namespace is required?
and what type is its input and output? is it binary?
Thanks for answer.
Bahman
|
|
|
|
|
Hi dudes,
could you Please help me with a code, to log errors into a text file using log4net in c#.. would appreciate your help if u help me asap.
many thanks
Thanks & Regards,
Vinothkumar V
|
|
|
|
|
Nothing in the documentation?
Kevin
|
|
|
|