?
Solved

Opening a new form

Posted on 2009-05-04
7
Medium Priority
?
326 Views
Last Modified: 2012-05-06
Hello,

I have one application that works okay.  I'm trying to integrate an on screen keyboard into it.  I tested the demo project and as a standlone it works fine.

I've added it into my project and created the following code to view the form:

        private void button1_Click(object sender, EventArgs e)
        {
            frmKeyboard frmKeyboard = new frmKeyboard();
            frmKeyboard.Show();
        }

It compiles but then just crashes when I click on the onscreenkeyboard.  The demo project I'm using can be found here:

http://www.codeproject.com/KB/miscctrl/touchscreenkeyboard.aspx?fid=285587&fr=26#xx0xx

Here is the code behind frmKeyboard.cs

Any suggestions as to what I might be doing wrong - I'm guesing the passing of data between forms is going wrong somewhere?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
namespace keyFortress
{
    public partial class frmKeyboard : Form
    {
        public frmKeyboard()
        {
            InitializeComponent();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            keyboardcontrol1.KeyboardType = KeyboardClassLibrary.BoW.Standard;
        }
        private void button2_Click(object sender, EventArgs e)
        {
            keyboardcontrol1.KeyboardType = KeyboardClassLibrary.BoW.Alphabetical;
        }
 
        private void button3_Click(object sender, EventArgs e)
        {
            keyboardcontrol1.KeyboardType = KeyboardClassLibrary.BoW.Kids;
        }
 
        private void keyboardcontrol1_UserKeyPressed(object sender, KeyboardClassLibrary.KeyboardEventArgs e)
        {
            richTextBox1.Focus();
            SendKeys.Send(e.KeyboardKeyPressed);
        }
 
        private void keyboardcontrol1_Load(object sender, EventArgs e)
        {
 
        }
    }
}

Open in new window

0
Comment
Question by:andyw27
[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
  • 5
  • 2
7 Comments
 
LVL 6

Expert Comment

by:Cebik
ID: 24293782
try:
frmKeyboard.ShowDialog();

please paste your exception
0
 

Author Comment

by:andyw27
ID: 24293804
This is giving the folloing error:
Error      1      An object reference is required for the non-static field, method, or property 'System.Windows.Forms.Form.ShowDialog()'
0
 
LVL 6

Accepted Solution

by:
Cebik earned 2000 total points
ID: 24293825
do you have this?

give me your exception with methode Show();

private void button1_Click(object sender, EventArgs e)
{
    frmKeyboard frmKeyboard = new frmKeyboard();
    frmKeyboard.ShowDialog();
}

Open in new window

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.

 

Author Comment

by:andyw27
ID: 24294272
Ah that was it, I was missing the first line.

Now the keyboard displays.

At the moment the letters appear within a richtextbox on frmKeyboard.  How can I change this so that letters appear within a control on frmMain?

Thanks.
0
 
LVL 6

Expert Comment

by:Cebik
ID: 24294319
i'm shure that there is better idea but you can do this:
but ShowDialog means that your main form is waiting for ending frmKeybord..
so make this:
 frmKeyboard frmKeyboard = new frmKeyboard();

as field in your frmMain class..
and in button_click
make only frmKeyboard.Show();

frmKeyboard frmKeyboard = new frmKeyboard();
frmKeyboard.TopMost = false;
frmKeyboard.Parent = yourPanelControl;
frmKeyboard.Show();

Open in new window

0
 
LVL 6

Expert Comment

by:Cebik
ID: 24294338

frmKeyboard fk = new frmKeyboard();
private void button1_Click(object sender, EventArgs e)
{
    fk.Parent = yourPanel; //Control
    fk.Show();
}

Open in new window

0
 
LVL 6

Expert Comment

by:Cebik
ID: 24294341
ups :)

frmKeyboard fk = new frmKeyboard();
private void button1_Click(object sender, EventArgs e)
{
    fk.TopMost = false;
    fk.Parent = yourPanel; //Control
    fk.Show();
}

Open in new window

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
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…
Suggested Courses
Course of the Month11 days, 6 hours left to enroll

770 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