|
You could override the control classes, or you could use CreateGraphics to draw your keys direct to the screen, then call Invalidate in the key up, so the form gets repainted.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Chris,
Yes I want to paint them on control but how to handle pressing of ALT+KEY ?
I dont want to use KeyPress, KeyDown events?
|
|
|
|
|
Vertyg0 wrote: I dont want to use KeyPress, KeyDown events?
Why on earth not ?
You can use a WndProc to catch these events earlier, but you really have no option but to use them, you want to catch when a key is down, and when it's raised again.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hello
You can set a property called KeyPreview to true in your form itself. Then handle KeyDown event in the Form level. It will catch any KeyDown events in any control in that form before it is sent to that control.
Regards
|
|
|
|
|
Try adding & in front of the letter that will be the hot key
Do your best to be the best
|
|
|
|
|
Hello. I am developing some classes that access SQL and Oracle databases.
These classes are to be used by different applications, (windows and web applications).
Thus, I need to put the database connection strings on a global location so that all applications see them (this way if I need to do changes to a connection string all applications are affected).
I found that machine.config might be a proper location to do that, under the <connectionstrings> section.
- Is machine.config a good solution for global connection strings?
- If so, how can I access the <connectionstrings> section in my code?
Thanks.
|
|
|
|
|
|
Dim loConn, lsSQL, loRs
Set loConn = CreateObject("ADODB.Connection")
' Open a connection to the database
loConn.Open("DSN=myDSN;UID=something;PWD=Something;")
' Insert a new record into the table
lsSQL = "SET NOCOUNT ON;" &_
"INSERT INTO tMembers (MemberName) VALUES ('Manohar');" &_
"SELECT @@IDENTITY AS NewID;"
' Execute the SQL statement
Set loRs = loConn.Execute(lsSQL)
' Get the inserted ID
llID = loRs.Fields("NewID").value
' Close the connection
loConn.Close()
Set loConn = Nothing
Hi guys,
What would be the equivalent code of the the above in C#? I have used ADO.NET a bit. How would i have to access the returend value (NewID). Would i have to pouplate a dataset or something? Is there a simple way to access single values returned by a database such as
SELECT DISTINCT store_name FROM Store_Information WHERE id = 5
Thanks!
|
|
|
|
|
The SQL would stay essentially the same in ADO.net.
Use an OledbCommand (or SqlCommand if using SQL Server) and do MyReader = mYcommand.ExecuteReader();
A datareader is analogous to a forward-only ADO recordset. I your examles above, you are reutuning recorsets that just happen to have only one row, one column. A datareader would do the same.
|
|
|
|
|
hello all,
I want Compress a folder that contain some files and subfolders.
how can i do it in visual C#.Net
-- modified at 6:36 Sunday 1st October, 2006
|
|
|
|
|
|
See here[^] maybe its some helpful for you
|
|
|
|
|
hi,
I want to use timer in my service ,but the timer never starts although i have put the start code of the timer in the onstart() method of the service.
|
|
|
|
|
I guess you're using the System.Windows.Forms.Timer . This one won't work as your service has no message pump. Try the System.Timers.Timer or System.Threading.Timer .
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hello.
I want to make an array of several controls for example buttons in my windows application.
is that possible in VS 2005?
Thanks everyone.
Please, Send me an answers to t_nedelchev@abv.bg.
t_nedelchev@abv.bg
|
|
|
|
|
Sure you can. Simply declare the array and assign a new or existing Button reference to it.
Button[] buttonarray = new Button[5];
for (int i = 0; i < buttonarray.Length; i++)
buttonarray[i] = new Button(); If you create the buttons dynamically don't forget to add them to the controls collection of your form or any container in it, so they get displayed.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Thanks for your fast reply, Stefan.
I wrote the code above.
this creates buttons, but they are invisible.
after your piece of code i wrote the following:
buttonarray.Location =...
buttonarray.size = ....
buttonarray.name = ...
buttonarray.tabindex = ...
buttonarray.text = ....
buttonarray.visible = ...
but again without success - there no buttons on my form.
what do i miss?
thanks.
|
|
|
|
|
As I said you have to add them to the controls collection of your form or any container in it. After all buttons are created, add the following line:
this.Controls.AddRange(buttonarray);
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Dear Stefan Troschütz, Thanks a lot. I made it.
|
|
|
|
|
hi i am try learn "push buttons events" & i stack on this.
i want on key ENETER push navigate on my pooor webBrowser
but this doesn work
1)
void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
// Navigate if the ENTER key is pressed
if (e.KeyChar == '\r')
Navigate();
}
2)
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if(e.Alt && e.KeyCode == Keys.E)
}
please tell me where prolem?
i am using VC#2005
tnx for help
i am noob in c#
|
|
|
|
|
At first I'm not really sure whether the keychar resulting from pressing enter is "\r". It would be better to check for it inside the KeyDown event handler e.KeyCode == Keys.Enter . This way you will also have your keyboard event handling in one place.
Secondly, are you sure the events are really fired (You may debug it)? Most probably your entering text in some other control, so the keyboard events of your form are only fired, if you set KeyPreview true. Either do this, or much better IMO register the KeyDown event handler to the control that's getting edited.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
i am type this
void Form1_KeyDown(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.Enter)
this.webBrowser1.Navigate(this.toolStripTextBox1.Text);
}
0 errors 0 warnings
& nothink hepend
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
Athlon 64 3500+, Gigabyte GA-K8NXP-9, 2x512 DDR400 Kingston, Inno3d 6200 PCIe, SS2 B2C2 v2.6, HDD := 450gb, Genius 56k int, NEC DVD-RW и мать его Суньмастер 550.
|
|
|
|
|
As I said, if you're entering text in some other control (probably the toolStripTextBox1), the keyboard events of your form aren't fired unless you set the KeyPreview property true . So either do this, or much better IMO register the KeyDown event handler to the control that's getting edited (toolStripTextBox1) cause otherwise Navigate will be executed whenever you're pressing enter.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
all what i done its
private void Form1_KeyDown(object sender,KeyEventArgs e)
{
if(e.KeyCode== Keys.Enter)
this.webBrowser1.Navigate(this.toolStripTextBox1.Text);
}
then just swith in properties of textbox
http://b.foto.radikal.ru/0610/87852a0cf72a.gif
& all work thx a lot
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
Athlon 64 3500+, Gigabyte GA-K8NXP-9, 2x512 DDR400 Kingston, Inno3d 6200 PCIe, SS2 B2C2 v2.6, HDD := 450gb, Genius 56k int, NEC DVD-RW и мать его Суньмастер 550.
|
|
|
|
|
If the KeyDown event handler is now registered to the ToolStripTextBox you should rename, so its obvious which KeyDown event it handles.
private void ToolStripTextBox1_KeyDown(object sender,KeyEventArgs e)
Also it would be a good idea to give the ToolStripTextBox a more descriptive name e.g. "toolStripTextBoxUrl".
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|