473,471 Members | 4,616 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to call bmp image for keypress event

2 New Member
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 1312

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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.