I've got KeyDown coding and it fires when other keys are pressed, but when Enter
is pressed, nothing.
I'd like to support the (standard?) Windows behavior of executing DblClick
processing when an item is selected and the user presses Enter
I got focus to stop moving to the next control via Tools|Options|K eyboard|Move
after enter....but now it just sits there and neither KeyDown nor KeyPress seems
to catch it.
Is this the end of the road?
--
PeteCresswell 7 8424
On Sat, 08 Jan 2005 20:10:17 GMT, "(Pete Cresswell)" <x@y.z> wrote: I've got KeyDown coding and it fires when other keys are pressed, but when Enter is pressed, nothing.
I'd like to support the (standard?) Windows behavior of executing DblClick processing when an item is selected and the user presses Enter
I got focus to stop moving to the next control via Tools|Options|K eyboard|Move after enter....but now it just sits there and neither KeyDown nor KeyPress seems to catch it.
Is this the end of the road? -- PeteCresswel l
Hi
The KeyDown and KeyUp events don't occur when you press the ENTER key
if the form has a command button for which the Default property is set
to Yes.
So maybe if you make sure it hasn't they will. You will have to to
trap and act on the enter key for command buttons yourself.
HTH
David
Per David Schofield: Hi The KeyDown and KeyUp events don't occur when you press the ENTER key if the form has a command button for which the Default property is set to Yes.
So maybe if you make sure it hasn't they will. You will have to to trap and act on the enter key for command buttons yourself. HTH
No Command buttons w/.Default=True - and I tested that by putting a regular
ListBox on the same form. The regular ListBox's KeyDown event fires when
Return/Enter are pressed (KeyCode=13).
It's starting to sound like the TreeView's behaviour is somewhat different.
--
PeteCresswell
On Sun, 09 Jan 2005 22:21:21 GMT, "(Pete Cresswell)" <x@y.z> wrote: Per David Schofield:Hi The KeyDown and KeyUp events don't occur when you press the ENTER key if the form has a command button for which the Default property is set to Yes.
So maybe if you make sure it hasn't they will. You will have to to trap and act on the enter key for command buttons yourself. HTH
No Command buttons w/.Default=True - and I tested that by putting a regular ListBox on the same form. The regular ListBox's KeyDown event fires when Return/Enter are pressed (KeyCode=13).
It's starting to sound like the TreeView's behaviour is somewhat different. -- PeteCresswel l
Hi
Um ...
You can set the form.KeyPreview = true and catch ENTER with KeyDown at
the form level, check that the treeview is active and in a suitable
state (use the treeview events to set up this) and then call your
doubleclick event. But the ENTER will still be passed to the treeview
control as KeyDown doesn't have a cancel argument.
Straightforward subclassing the treeview doesn't catch Enter, but if
you are up for heavy coding see
How To Prevent the ENTER Key From Firing in TreeView Control http://support.microsoft.com/default...b;en-us;216664
This is written for VB.
It is a bold developer who deploys any Access app with treeview in it,
let alone one with subclassing!
David
HTH
David
Per David Schofield: It is a bold developer who deploys any Access app with treeview in it, let alone one with subclassing!
I've got a couple out there with no reported problems.
("Reported" being the operative word....)
Anything special I should be on the lookout for?
--
PeteCresswell
Per David Schofield: ou can set the form.KeyPreview = true and catch ENTER with KeyDown at the form level, check that the treeview is active and in a suitable state (use the treeview events to set up this) and then call your doubleclick event. But the ENTER will still be passed to the treeview control as KeyDown doesn't have a cancel argument.
Still no-go.
I checked it with ?frmWhatever.Ke ypreview in the immediate window....and,
indeed, it still fires KeyDown and KeyPress for the space bar and other
keys...but not Enter.
I think I see why, though. The list is already using Enter to toggle nodes'
..Expanded. Hit Enter on a collapsed node and it expands...do the same thing
on an expanded node and it collapses.
I guess that about wraps it.... I guess I'll just trap SpaceBar and tell the
users to learn to love it.
--
PeteCresswell
On Tue, 11 Jan 2005 00:44:22 GMT, "(Pete Cresswell)" <x@y.z> wrote: Per David Schofield:It is a bold developer who deploys any Access app with treeview in it, let alone one with subclassing!
I've got a couple out there with no reported problems.
("Reported" being the operative word....)
Anything special I should be on the lookout for? -- PeteCresswel l
Hi
Problems with common controls arise mainly in MDE/run time systems
when older or newer versions of the DLL are on the user's PC
David
I was just myself searching for a solution to the above problem without any luck, but as I did find (partly based on the above) a solution I will post it here, even if it is a quite old thread.
First you must ensure that the Form previews the key pressed before the control. Enter your form properties and find the property called "Key Preview" and set it to TRUE.
This part is optional, but I decided to add a public enum to make it easier for myself to see the keycodes, so this goes into a public module: - Public Enum Keys
-
Enter = 13
-
Spacebar = 32
-
NoKey = 0
-
End Enum
Now write code for the Key_Down event of the form, and notice I use it for both my treeview and my listview: - 'Only react to keyStroke=enter(13)
-
If KeyCode <> Keys.Enter AND Keycode<>Keys.Spacebar then Exit Sub
-
-
'Respond accordingly to which control is the active control
-
Select Case Me.ActiveControl.Name
-
Case Me.TreeProjects.Name
-
'Treeview is active, determine active node (if any)
-
Dim tv As TreeView
-
Set tv = Me.TreeProjects.Object
-
If Not tv.SelectedItem Is Nothing Then
-
Custom_TreeProjects_NodeSelect tv.SelectedItem
-
End If
-
-
'Cancel enter keystroke
-
KeyCode = Keys.NoKey
-
-
Case Me.listReports.Name
-
Select Case KeyCode
-
Case Keys.Enter
-
-
Case Keys.Spacebar
-
Dim lv As MSComctlLib.ListView
-
Set lv = Me.listReports.Object
-
If Not lv.SelectedItem Is Nothing Then
-
OpenReport getID(lv.SelectedItem)
-
End If
-
End Select
-
'Cancel enter keystroke
-
KeyCode = Keys.NoKey
-
-
End Select
-
-
exitSub:
-
Set tv = Nothing
-
Set lv = Nothing
-
-
-
End Sub
The Original poster doesn't say so, but I think when he tried this, he kept using the Treeviews KeyDown event, after turning on Key Preview, and thus failed to move the tracking into the forms Key_down (Which occurs any control reacts to Key_Down, thus why it is called Preview)
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Hrvoje Voda |
last post by:
What is wrong in this code?
private void tree_KeyDown(object sender, System.Windows.Forms.KeyEventArgs
e)
{
if (e.KeyCode == Keys.Enter )
{
|
by: Matthew Wieder |
last post by:
Hi - I wanted to capture the enter button on a form since I have a
datagrid with the first column being a delete button and if someone hits
enter it deletes the first record. I coded:
private void Page_Load(object sender, System.EventArgs e)
{
Page.RegisterHiddenField("__EVENTTARGET","SomeButtonOnThePage");
|
by: clsmith66 |
last post by:
In a treeview, I am trying to store the index of every treenode as it expands
in a hidden input box. If I click on the node itself, it expands and I can
capture the node index no problem. If I click on the plus sign however, the
selected index doesn't change so I can't capture the index of the newly
expanded node. Does any one know how to change the selected node when a plus
sign is clicked?
|
by: ewillyb |
last post by:
Hi,
ASP.NET has some interesting behavior when the user hits the Enter key.
If there are multiple ASP:Buttons (rendered as HTML submits) on the
form, when the user hits enter, the first button's click event will
fire and the page will submit.
I have a series of pages with Previous and Next navigational Btns. The
Previous button is the first button, so when the user hits enter, the
previous page is served up. Enter should result in...
|
by: Bernie Yaeger |
last post by:
I have an mdi app that has a main menu on the parent form. I would like to
use a treeview in place of one of the menu options, so that instead of a
menu option - say, 'reports' - it would have 'reports' but the second level
would not be menu items for each report but rather a treeview control which,
when clicked, would produce the appropriate report.
Essentially, then, what I want to do is use a treeview where a sub menu list
ordinarily...
| |
by: ali element via .NET 247 |
last post by:
(Type your message here)
--------------------------------
From: ali element
Hi,
I have a IE treeview which I can populate on the fly. However,when I hit the page the following property must be set
<%@ Page Language="VB" EnableViewStateMac="True" Debug="true"AutoEventWireUp="true" %>
|
by: rolf.oltmans |
last post by:
Hello all,
I need to place treeview control in Grid control. I need to place it in
a grid because I need to show calendar against every node. Is placing a
treeview in grid possible? If I need to create my own control that
would include capabilities of both treeview and Grid what would I have
to do? Being new to asp.net I guess I've to make a control that would
inherit from treeview and grid. But would changes I've to make in my...
|
by: hardieca |
last post by:
Hi,
I have created a treeview bound to a sitemap provider. I have put it
into a user control (the control will be used for similar, but not
always identical, functionality).
The treeview expresses the hierarchy of sections in my website. In a
page that edits sections, I would like to use the treeview to allow
the user to select a parent section. My treeview is accurately showing
my section tree, but of course when I click a link I am...
|
by: krissco |
last post by:
Hello Group,
I was having the same issue as described here:
http://groups.google.com/group/comp.databases.ms-access/browse_thread/thread/4cb8b9fdc4c107ec/8d6da68840ec0ae9?lnk=gst&q=treeview+%22capture+enter%22#8d6da68840ec0ae9
I just realized a solution to this issue:
Place a button on the form. Set the "Default" property of the button
to TRUE.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |