Solved

Using controls

Posted on 2006-06-08
8
218 Views
Last Modified: 2010-04-23
I am using VB.NET 2005 version.In my Main Form I have Buttons like Close,Find,Add,Delete etc.Instead of using buttons in each form,i call these buttons. and they are working properly.

My Question is when  I click (Ctrl+F) I want to display find form,
 How i do that.

The find will work when i will click the find button,properly.I just want it will work also when i will click (Ctrl+F) .Any button property of find? or any other method
0
Comment
Question by:lincyelias
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 11

Expert Comment

by:anyoneis
ID: 16867905
I'm not clear what you want. Are you saying that you want to call the button click routines in your main form from a sub form, when certain keystroke combinations are pressed?

David
0
 

Author Comment

by:lincyelias
ID: 16867953
Sir,

In My main Form I have a Button 'btnFind'.If I Click that btnFind, it will call a function Find().

I also want when I use (Ctrl+F),it must call the function Find().
0
 

Author Comment

by:lincyelias
ID: 16868048
Any Button Property can set (Ctrl+F)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Expert Comment

by:anyoneis
ID: 16870539
Try this post - it sounds very similar to what you are looking for:

http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_21857861.html

David
0
 
LVL 11

Expert Comment

by:anyoneis
ID: 16873584
Actually, it looks like KeyDown is the event you want to subscribe to, not keypress. As in:

[code]
        void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            Console.WriteLine("Control is {0} and KeyValue is {1}", e.Control, e.KeyCode);
            if (e.Control  && e.KeyCode.Equals(Keys.F))
            {
                DoFStuff();
                e.Handled = true;
            }
        }

[/code]

David

Then, when you create a subform:

            Form subForm = new SubForm1();
            subForm.KeyDown += Form1_KeyDown;
            subForm.Show(); // or subForm.ShowDialog()

David
0
 

Author Comment

by:lincyelias
ID: 16875676
Sir,

U write the code in C#.in VB.net there is no keydown events.so can you write it in VB.net.
Thank You Sir
0
 
LVL 11

Accepted Solution

by:
anyoneis earned 60 total points
ID: 16875919
It is pretty much the same in VB. Here is what I came up with:

Public Class Form1

    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
        Console.WriteLine("Control is {0} and KeyValue is {1}", e.Control, e.KeyCode)
        If e.Control AndAlso e.KeyCode.Equals(Keys.F) Then
            DoCtlFStuff()
            e.SuppressKeyPress = True
            e.Handled = True
        End If
    End Sub

    Private Sub DoCtlFStuff()
        MessageBox.Show("CtlFStuff")
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.KeyPreview = True
        AddHandler Me.KeyDown, AddressOf Form1_KeyDown
    End Sub


    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim subForm As Form = New SubForm1()
        AddHandler subForm.KeyDown, AddressOf Form1_KeyDown
        subForm.Show() ' or subForm.ShowDialog()
    End Sub
End Class


Ciao!
David
0
 

Author Comment

by:lincyelias
ID: 16884602
Thank Yoo Sir
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question