---
title: "how to call bmp image for keypress event"  
description: "how to call bmp image for keypress event"  
author: "Madhu Mitha"  
published: 2015-04-24  
updated: 2015-04-25  
canonical: https://www.mindstick.com/forum/23134/how-to-call-bmp-image-for-keypress-event  
category: ".net"  
tags: ["vb.net"]  
reading_time: 3 minutes  

---

# how to call bmp image for keypress event

hai..\
\
I need something to do where I [stored](https://www.mindstick.com/forum/157561/what-is-the-stored-procedure-create-a-procedure-to-find-the-record-by-stu_id-from-the-student-table) bmp [images](https://www.mindstick.com/interview/1067/what-is-the-php-predefined-variable-that-tells-the-what-type-of-images-that-php-support) for alphabets and numbers and i call call those images when i type it in a textbox.\
I have a [sample](https://www.mindstick.com/news/2174/mars-mission-by-nasa-prepares-for-tests) [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) like\
\

```
Public Class Form1    Dim graph As Graphics    Dim g, g1 As System.Drawing.Graphics    Dim img As New Bitmap(144, 16)    Dim brush As New Drawing.SolidBrush(Color.Black)    Private Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.TextChanged        g1 = Graphics.FromImage(img)        PictureBox1.Image = img        ' to clear the bitmap        g1.Clear(Color.White)        'for drawsting function        g1.SmoothingMode = Drawing2D.SmoothingMode.HighQuality        g1.TextRenderingHint = Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit        g1.CompositingQuality = Drawing2D.CompositingQuality.HighQuality        'to draw string        g1.DrawString(TextBox1.Text, TextBox1.Font, Brushes.Black, 0, 0)        PictureBox1.SizeMode = PictureBoxSizeMode.Normal        PictureBox1.Refresh()    End SubEnd Class
```

I have a seperate code for [keypress event](https://www.mindstick.com/forum/160753/how-to-use-a-keypress-event-in-angularjs) as \
\

```
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress        Dim file As String = String.Format("{0}\{1}.bmp", Application.StartupPath, e.KeyChar.ToString)         If System.IO.File.Exists(file) Then             PictureBox1.ImageLocation = file         Else             PictureBox1.ImageLocation = String.Empty         End If    End Sub
```

but i could call these [functions](https://www.mindstick.com/forum/160140/explain-the-role-of-functions-as-a-service-faas-in-serverless-computing) to my [program](https://www.mindstick.com/blog/12337/scaling-up-your-mentorship-program)\
and aslo i could not call more than one bmp [image](https://www.mindstick.com/articles/23551/an-investigate-distinctive-seafood-restaurant-for-your-image-stamp-character) in mypicturebox..\
can any one help me..

## Replies

### Reply by Madhu Mitha

Okay.. I will try to do it.. Thank you..

### Reply by Sunil Singh

you can use imagelist control or dynamically create picturebox . On textbox key press event create dynamic picturebox and set image to dynamically created picturebox according to keychar.

### Reply by Madhu Mitha

Is there any other option to do so..

### Reply by Sunil Singh

you can only able to set one image in picture box at a time.\

### Reply by Madhu Mitha

I just needed when i press the keys in textbox.. So how it wil be useful when i do with button click.. whenever i type in my textbox the images should be called..

### Reply by Jack C

Then do not place images on keypress event , use button click event to place images on your picture box.\

### Reply by Madhu Mitha

hai Jack..\
\
Yes I need like that.. if I pass ABCD as my input.. Then bmp images of ABCD should be displayed in my picturebox

### Reply by Jack C

You mean to say if someone has pressed A B C D then images of A B C D alphabets should be placed in your picturebox or You want to store previously pressed alphabets images in your picturebox?\

### Reply by Madhu Mitha

hai sunil..\
The specified file exists in my application start up path.. but as u said i can place oly one image in my picturebox.. but i need to place multiple bmp images in my picturebox.. how can I do it\

### Reply by Madhu Mitha

hai john..\
Because, instead of calling normal font for my application i need to call bitmap images of alphabets numbers and special characters.. so whenever i press my keys the relavent alphabet should place in my picturebox..

### Reply by Sunil Singh

There is no problem in your function, you only need to check specified file exist at the given path (Application.StartupPath) .\
and also you can only able to set one image in picture box at a time\

### Reply by John Smith

Why you calling images on the keypress [event](https://www.mindstick.com/articles/167719/marquee-hire-benefits-of-event-lighting-hire-london) of textbox? \
\


---

Original Source: https://www.mindstick.com/forum/23134/how-to-call-bmp-image-for-keypress-event

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
