473,395 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

how to call bmp image for keypress event

hai..

I need something to do where I stored bmp images for alphabets and numbers and i call call those images when i type it in textbox.
i have a sample code like
Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.     Dim graph As Graphics
  3.     Dim g, g1 As System.Drawing.Graphics
  4.     Dim img As New Bitmap(144, 16)
  5.     Dim brush As New Drawing.SolidBrush(Color.Black)
  6.     Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
  7.         g1 = Graphics.FromImage(img)
  8.         PictureBox1.Image = img
  9.         ' to clear the bitmap
  10.         g1.Clear(Color.White)
  11.         'for drawsting function
  12.         g1.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  13.         g1.TextRenderingHint = Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit
  14.         g1.CompositingQuality = Drawing2D.CompositingQuality.HighQuality
  15.         'to draw string
  16.         g1.DrawString(TextBox1.Text, TextBox1.Font, Brushes.Black, 0, 0)
  17.         PictureBox1.SizeMode = PictureBoxSizeMode.Normal
  18.         PictureBox1.Refresh()
  19.     End Sub
  20. End Class
  21.  
i have a seperate code for keypress event as
Expand|Select|Wrap|Line Numbers
  1. Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
  2.         Dim file As String = String.Format("{0}\{1}.bmp", Application.StartupPath, e.KeyChar.ToString)
  3.  
  4.         If System.IO.File.Exists(file) Then
  5.  
  6.             PictureBox1.ImageLocation = file
  7.  
  8.         Else
  9.  
  10.             PictureBox1.ImageLocation = String.Empty
  11.  
  12.         End If
  13.     End Sub
but i could call these functions to my program
and aslo i could not call more than one bmp image in mypicturebox..
can any one help me..
Apr 25 '15 #1
0 1311

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: William Ortenberg | last post by:
I'm trying to capture when a user presses a particular key (escape), so I'm coding in the KeyPress event. Yet the code seems be bypassed (breakpoint is never encountered). Should I be coding in a...
0
by: mevar81 | last post by:
Hello to everybody.I have a problem.I have a property grid that display several properties of a object.I have a properties that store the image but I want to display the file name.So I have...
0
by: news.gorge.net | last post by:
I want to fire an event when a user presses Control+C when NOT in a situation where that keypress combo would copy something to the clipboard. My current attempt was to override the...
3
by: Darryn Ross | last post by:
Hi, I am trying to catch the KeyPress event on my datagrid but it isn't working... i have also tried registering the handler with the event like this... dgGLBatch.KeyPress += new...
3
by: Raul M. Colon | last post by:
Is possible to assign a click event to a button control in a Web form just pressing the return key? Something like windows forms where you can assign this action to a default control. For example,...
4
by: Tom | last post by:
I have a VB.NET user control that I wrote - this control has three or four other controls on it (textbox, combobox, datetime picker, etc). Now, whenever the control is on a form and the user enters...
3
by: Terry Olsen | last post by:
Is there anyway to cause a KeyPress event in a datagrid cell? The only way I get a keypress event is if none of the cells are selected. I was hoping to have the program respond to a certain...
3
by: Nikolay Evseev | last post by:
Hi, I am trying to trace down the Enter key in my Form.KeyPress event handler. The KeyPreview property is set to false, so I'd assume that all key presses should go through my form's KeyPress...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.