---
title: "To scroll a text in picturebox, save a picturebox in .txt format"  
description: "To scroll a text in picturebox, save a picturebox in .txt format"  
author: "Madhu Mitha"  
published: 2015-03-19  
updated: 2015-03-20  
canonical: https://www.mindstick.com/forum/23033/to-scroll-a-text-in-picturebox-save-a-picturebox-in-txt-format  
category: ".net"  
tags: ["vb.net"]  
reading_time: 3 minutes  

---

# To scroll a text in picturebox, save a picturebox in .txt format

Hi,\
I am new to .Net an need help in my application.\
I want to scroll my text in a picturebox.. i used drawstring [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) to draw the text an now i want to make it scrollable..My Code is\
[Private](https://www.mindstick.com/blog/11097/java-access-modifiers-the-public-and-the-private-modifiers) Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim scale_factor As Single = Single.Parse(cmbdest.Text)\
' Get the [source](https://www.mindstick.com/interview/840/what-happens-if-the-both-source-and-destination-are-named-same) [bitmap](https://www.mindstick.com/forum/1924/find-image-format-using-bitmap-object-in-c-sharp). Dim bm_source As New Bitmap(Size.Width, Size.Height, Drawing.Imaging.PixelFormat.Format24bppRgb)\
' Make a bitmap for the [result](https://www.mindstick.com/blog/12011/advantages-of-getting-result-oriented-seo-from-an-agency). Dim bm_dest As New Bitmap( _ CInt(bm_source.Width * scale_factor), _ CInt(bm_source.Height * scale_factor))\
'Make a [Graphics](https://www.mindstick.com/articles/336067/html-graphics-using-html) object for the result Bitmap. Dim gr_dest As Graphics = Graphics.FromImage(bm_source) End Sub\
Private Function DrawText(ByVal Text As [String](https://www.mindstick.com/articles/1527/string-split-in-c-sharp)) As Bitmap Dim TextBitmap As New Bitmap(Text) Dim Brush As New SolidBrush(Color.Black) Dim SelectedFont = New Font(FontFamily.GenericSansSerif, 50) Using Graphic = Graphics.FromImage(TextBitmap) Graphic.DrawString(Text, SelectedFont, Brushes.Black, 0, 0) End Using Return TextBitmap End Function Private Sub img(ByVal route As String, ByVal font As String, ByVal fnsize As [Integer](https://answers.mindstick.com/qa/113667/write-code-for-roman-to-integer), ByVal x As Integer, ByVal y As Integer) PictureBox1.Image = Nothing Dim g2 As System.Drawing.Graphics Dim img As New Bitmap(Size.Width, Size.Height, Drawing.Imaging.PixelFormat.Format24bppRgb) g2 = Graphics.FromImage(img) g2.SmoothingMode = Drawing2D.SmoothingMode.HighQuality g2.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit g2.CompositingQuality = Drawing2D.CompositingQuality.HighQuality Try g2.DrawString(route, New Font(font, fnsize), Brushes.White, x, y) Catch ex As [Exception](https://www.mindstick.com/articles/1824/objective-c-exception-handling) MessageBox.Show("this font not supported try another font") End Try PictureBox1.SizeMode = PictureBoxSizeMode.Normal\
PictureBox1.Image = img End Sub\
in the same function i have to save the file in .txt format and .bmp format..Kindly help me..thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)

## Replies

### Reply by Madhu Mitha

hai Sumit,\
I get text from a combobox and i displayed it in a picturebox... so using drawstring function i could not scroll my text or save my picturebox as an image.. can u help me please..

### Reply by Sumit Kesarwani

Hi Madhu, you can use the paint event of the picturebox to draw the text, like this:\

```
 private void pictureBox1_Paint(object sender, PaintEventArgs e)        {            using (Font myFont = new Font("Arial", 14))            {                e.Graphics.DrawString("Display Text", myFont, Brushes.Green, new Point(2, 2));            }        }
```

### Reply by Madhu Mitha

hi sumit,\
sir, its a kind of working with pixels and mapping .. Dis work gonna be used with lcd n led board.. i wanna make a display board which is used in MTC Buses.. So thought of using picturebox.. the output generated should be converted to an binay file..\
\
![To scroll a text in picturebox, save a picturebox in .txt format](https://www.mindstick.com/mindstickforums/4d44ebeb-a323-4e3b-b5e8-045c6fa06a1b/images/85e2de47-aa7e-4cd8-9ee4-cb455cdc8d29.png)\
\
i need an output like dis.. where no, destination and via routes should fix in same box.. I dono how to implement it.. can u help me with dis.. \

### Reply by Sumit Kesarwani

Hi Madhu, If you are working with text, then why you want to use the picturebox, instead of using the picturebox use either textbox or richtextbox and you can scroll the text in both by making them multiline.


---

Original Source: https://www.mindstick.com/forum/23033/to-scroll-a-text-in-picturebox-save-a-picturebox-in-txt-format

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
