Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using controls

Posted on 2006-06-08
8
Medium Priority
?
225 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 240 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

Industry Leaders: 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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

722 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