Solved

Using controls

Posted on 2006-06-08
8
194 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
  • 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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 …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

861 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now