Click here to Skip to main content
15,747,139 members
Home / Discussions / C#
   

C#

 
GeneralRe: Showdialog() question Pin
OriginalGriff13-Nov-15 4:04
mvaOriginalGriff13-Nov-15 4:04 
QuestionEvent that fires on existing form when another is selected Pin
Member 1212588812-Nov-15 9:58
Member 1212588812-Nov-15 9:58 
AnswerRe: Event that fires on existing form when another is selected Pin
Richard Andrew x6412-Nov-15 10:12
professionalRichard Andrew x6412-Nov-15 10:12 
AnswerRe: Event that fires on existing form when another is selected Pin
BillWoodruff12-Nov-15 10:57
professionalBillWoodruff12-Nov-15 10:57 
QuestionHow to design a keypad in C#? Pin
naouf1012-Nov-15 9:34
naouf1012-Nov-15 9:34 
AnswerRe: How to design a keypad in C#? Pin
BillWoodruff12-Nov-15 10:40
professionalBillWoodruff12-Nov-15 10:40 
AnswerRe: How to design a keypad in C#? Pin
Gerry Schmitz13-Nov-15 1:37
mveGerry Schmitz13-Nov-15 1:37 
AnswerRe: How to design a keypad in C#? Pin
GrooverFromHolland13-Nov-15 15:40
GrooverFromHolland13-Nov-15 15:40 
Hi
If You are new to C# it wont be easy.
First of all You can not use buttons, because when You click a button that button will steal focus, so your key stroke will have no notion where to go.
The only (winforms)control that not steals focus is a label, but a label has not got the right properties to act as a key.
The solution is to create a custom control derived from label control.
to do so You must add this class to your project:
C#


C#
namespace YOURPROJECTNAMESPACE
{
    public sealed class MyControl : Label
    {
        public MyControl()
        {
            // Allow transparent background
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            // Default to transparent background
            BackColor = Color.Transparent;
        }

        public Image ControlImage { get; set; }

        protected override void OnPaint(PaintEventArgs e)
        {
            // Draw image, sized to control
            if (ControlImage != null)
            {
                e.Graphics.DrawImage(ControlImage, 4, 4, Width - 8, Height - 8);
            }
            // Draw text, centered vertically and horizontally
            var rectangle = new RectangleF(2, 0, Width, Height + 5);
            var format = new StringFormat
            {
                LineAlignment = StringAlignment.Center,
                Alignment = StringAlignment.Center
            };
            e.Graphics.DrawString(Text, Font, Brushes.Black, rectangle, format);
        }
    }
}


After you have done this You will find in the designer toolbox MyControl.

Then drag a flowLayouPanel from the toolbox. Populate this panel by dragging as many MyControls as you need. in properties give them a nice picture of a key and a character as text.
One more thing to do, In the designer doubleclick each key,and in the click event this:
C#

C#
private void myControl1_Click(object sender, EventArgs e)
       {
           SendKeys.Send("{1}");
       }


C#
private void myControlEnter_Click(object sender, EventArgs e)
       {
           SendKeys.Send("{ENTER}");
       }


Etc.

If You have any more questions just ask,

Groover
0200 A9 23
0202 8D 01 80
0205 00


modified 13-Nov-15 21:47pm.

GeneralRe: How to design a keypad in C#? Pin
BillWoodruff14-Nov-15 8:39
professionalBillWoodruff14-Nov-15 8:39 
Generalcreating a packet using c# or vb Pin
Member 1140244512-Nov-15 2:52
Member 1140244512-Nov-15 2:52 
GeneralRe: creating a packet using c# or vb Pin
John Torjo12-Nov-15 3:40
professionalJohn Torjo12-Nov-15 3:40 
GeneralRe: creating a packet using c# or vb Pin
Dave Kreskowiak12-Nov-15 3:53
mveDave Kreskowiak12-Nov-15 3:53 
GeneralRe: creating a packet using c# or vb Pin
Member 1140244512-Nov-15 4:44
Member 1140244512-Nov-15 4:44 
GeneralRe: creating a packet using c# or vb Pin
Gerry Schmitz12-Nov-15 6:57
mveGerry Schmitz12-Nov-15 6:57 
Questionin c#. how to serilialize and deserialize object with object of other classes inside it??? Pin
Member 1212766511-Nov-15 23:08
Member 1212766511-Nov-15 23:08 
AnswerRe: in c#. how to serilialize and deserialize object with object of other classes inside it??? Pin
Pete O'Hanlon11-Nov-15 23:16
subeditorPete O'Hanlon11-Nov-15 23:16 
GeneralRe: in c#. how to serilialize and deserialize object with object of other classes inside it??? Pin
John Torjo12-Nov-15 2:56
professionalJohn Torjo12-Nov-15 2:56 
GeneralRe: in c#. how to serilialize and deserialize object with object of other classes inside it??? Pin
Dave Kreskowiak12-Nov-15 4:10
mveDave Kreskowiak12-Nov-15 4:10 
GeneralRe: in c#. how to serilialize and deserialize object with object of other classes inside it??? Pin
Member 1212766512-Nov-15 2:58
Member 1212766512-Nov-15 2:58 
AnswerRe: in c#. how to serilialize and deserialize object with object of other classes inside it??? Pin
Richard Andrew x6412-Nov-15 3:08
professionalRichard Andrew x6412-Nov-15 3:08 
AnswerRe: in c#. how to serilialize and deserialize object with object of other classes inside it??? Pin
Bernhard Hiller12-Nov-15 4:12
Bernhard Hiller12-Nov-15 4:12 
GeneralRe: in c#. how to serilialize and deserialize object with object of other classes inside it??? Pin
BillWoodruff12-Nov-15 5:45
professionalBillWoodruff12-Nov-15 5:45 
AnswerRe: in c#. how to serilialize and deserialize object with object of other classes inside it??? Pin
BillWoodruff12-Nov-15 6:03
professionalBillWoodruff12-Nov-15 6:03 
AnswerRe: in c#. how to serilialize and deserialize object with object of other classes inside it??? Pin
Member 1212766512-Nov-15 21:26
Member 1212766512-Nov-15 21:26 
Questionrun file with associated extension in current instance (ddeexec?) Pin
robinsc10-Nov-15 9:51
robinsc10-Nov-15 9:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.