Solved

Using controls

Posted on 2006-06-08
8
213 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
Independent Software Vendors: 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

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!

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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

735 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