.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Draw text on screen, one line and then next (GDI+)

Posted By:      Posted Date: September 29, 2010    Points: 0   Category :.NET Framework

I want to draw some lines on screen, one line and then next, just likes you see the subtitle of a movie.

but they overlaped, and I just get a black rect in the end.

It is not repainted between every drawing, so i want to know how to force to repaint.

It is to screen, not form. thx.


private void Show(string line)
  IntPtr desk = GetDesktopWindow();
  IntPtr hdc = GetDCEx(desk, IntPtr.Zero, 1027);
  //RedrawWindow(desk, Rectangle.Empty, IntPtr.Zero, 0x85);
  Graphics g = Graphics.FromHdc(hdc);
  g.DrawString(line, this.Font, new SolidBrush(forecolor), new PointF(Screen.GetWorkingArea(this).Width - 500,
  Screen.GetWorkingArea(this).Height - 60));

View Complete Post

More Related Resource Links

Mission Impossible? Use Javascript to Disable a Multi-Line Rich Text Field


Hey Community,

Here's a tough one that I have struggled with and so far have not been able to find an answer for - how do you use Javascript to disable a multi-line rich text field.  I have customized a SP Edit form by adding a CEWP.  In the CEWP I have added the Javascript below (only a partial code sample provided) to disable several fields in the form.  The code works fine for single line text fields but it does not work for multi-line rich text fields.  Any suggestions?

<script language="javascript">
//This runs the function when the form first loads

//This locks the fields the users should not modify
function lockFields()
  var theInputTFTitle = getTagFromIdentifierAndTitle("Input","TextField","Title");
  theInputTFTitle.readOnly = true;
  theInputTFTitle.style.color = 'gray';
  //alert(" Value: " + theInputTFTitle.value);//for testing

   var theInputDDLReplyStatus = getTagFromIdentifierAndTitle("select","DropDownChoice","Reply Status");
  theInputDDLReplyStatus.disabled = true;
  //alert(" Value: " + theInputDDLReplyStatus.value);//for testing

  var theInpu

Deleting Last Line of Text in a text file

Hi, I needed some help on the best way to delete the last line of  text in a text file. I have a subroutine that looks like this, but it is missing some code. Could anyone advise me on this? Dim strLogFile As String = System.Web.HttpContext.Current.Server.MapPath("~/Log.txt")         Dim fs As New FileStream(strLogFile, FileMode.Open, FileAccess.ReadWrite, FileShare.None)         Dim swLog As New StreamReader(fs)         Dim array As String()         Dim value As String = swLog.ReadToEnd ''Array that holds the lines of the text file.         array = value.Split(vbCrLf)        ''code for deleting last line: . . .  fs.Close()

putting carriage return/line feed in non-HTML email text

Using vb.net/asp.net 2005I am trying to create a string message for an email that I am sending out from my asp.net page like so: For Each dr In dtDataTable.Rows strMessage = strMessage & vbCrLf & vbCrLf & Environment.NewLine & dr.Item("UserName") & Environment.NewLine Next so I am looping through a datatable and getting each name from each row, that is working well but when I get the email it appears in my inbox with all the names mashed together, you see I am trying both vbcrlf and newline but looks like neither is workingdoes anyone know what I'm doing wrong?

Display each new line of a sharepoint mutliline text field as choice in drop down box.

The question pretty much says it all. I have a lot of data I need to represent, and this would be the best way to do it. I have a multiline text field in sharepoint, where each line has a choice that should be a seperate choice in a text box. How do I do this? I have the data connection set up, and I would be fine with adding some sort of tag after each line, if that would make it so infopath can somehow parse out those tags, and interpret each "chunk" as a choice. Thanks in advance for your help.

Infopath browser form - odd behaviour on auto expanding multi line text boxes




I have a browser form with a multi line text box. The height is set to be AUTO. Within the client all is fine. When opened as an administrator approved form the text box automatically adds a new line for every 20 characters you type.


So if you type 40 characters without pressing enter you get 2 blank lines appear under you text that you CANNOT remove.


I have tested this on a new form with various multi line text boxes. The width setting is unimportant, the spell check setting is unimportant.


If i fix the height then the issue goes away but this is not any good.


I cannot use rich text boxes as i have around 40 text boxes on the form and if they are rich text they take around 10 minutes to load in the browser (this is another issue i have)


Thanks in advance



How to read/write GIANT text file with no line breaks


I have to process giant XML files that are 6GB+ in size.  The problem is that there are no line breaks in the file, and the XML is improperly formatted (no root element).  Therefore I can't use the XML class to read the file, and I can't open the file in any text editor or even "Type" it in a command window because the 1 line in the file is over 6GB.

The file contains UTF8 characters.  What I want to do is first write a program just to read and display 100 characters at a time so I can look at the contents.  Next I want to be able to create a new file, write a root element, read/write the contents of the file and then write the closing root element.

Can anyone provide a code snippet of how to read and display the file contents 100 characters at a time.  I can then figure out the rest.


Random line from a text file



Im trying to pull a random line from a text file and store it into a variable.

I found this piece of code on the web which looks good but I cant seem to get it working in vs 2010, any ideas ?

Dim MyString As String
Dim MyBuffer() As Byte
Open "C:\AFile.txt" For Binary Access Read As #1
  ReDim MyBuffer(LOF(1) - 1)
  Get 1, , MyBuffer
  MyString = StrConv(MyBuffer, vbUnicode)
  ReDim MyBuffer(0) 'Free up memory
Close #1

Many thanks in advance.


C# Snippet Tutorial - How to Draw Text on an Image

In this snippet tutorial we're going to be adding on to our series of C# image editing tutorials. This tutorial is going to provide the code required to do basic text drawing including anti-aliasing and text alignment.

For more information on C# image editing, check out our previous two tutorials: C# Tutorial - Image Editing: Saving, Cropping, and Resizing and C# Tutorial - Image Editing: Rotate.

Ok, let's get started. The first thing we need to do is get a Bitmap object from an image file.

Bitmap myBitmap = new Bitmap("C:\\myImage.jpg");

Now that we have a Bitmap object we can get a Graphics object from it. The Graphics object will be doing all of our text drawing.

draw vertical line


how can I draw a vertical line in ASP.NET betwwn two as:TableCell to occupy 100% height?

Form Services 2010 - potential bug in plain text - multi-line boxes



Just wondering if anyone else has found the following and perhaps a resolution.  (Blog post with image examples here: Click)


An InfoPath Form created in Microsoft InfoPath Designer 2010 and is installed as an Administrator approved template.

  • Form Control: Text Box


  • Read-only – No
  • Enable spelling checker – Yes
  • Enable AutoComplete – Yes
  • Multi-line – Yes


  • Height: Auto

Compatibility Settings:

  • Form Type: Web Browser Form (2010)


  • Browser: Internet Explorer 7, 8, Google Chrome

When running the Form in the web and a user types into the multi-line text box; after 20 characters the text box gets bigger by 1 row.

On evaluation using the IE8 development toolbar.  It would appear that the control is rendered as a <textarea> HTML element and JavaScript runs on the 22<sup>nd</sup> character and adds 1 to the “rows” attribute of the <textarea> element.

For example:

InfoPath Form and Multi-line Text box


I'm using a multi-line textbox in my infopath form, the text scorlls when user enter texts that exceed the width/height of the text box, thats fine. But after user submits the form, the textbox just dsiplays one line of text with with "..." at the end and user needs to use "End" key or drag the text using the mouse key to see the remaining text. We want to display all the text that user entered instead of "...". What setting needs to be done in the inforpath forms.

Also I wanted to know if there is any known issue using Rich Text field in Infopath form with SharePoint InfoPath service.

Thanks in advace,

WPF: what control we should use if we need draw a line between to textBlock?


We need draw a line between two textBlocks.

The two textblocks position will change base on the given space.

So we hope the line width will automatically change base on two textblocks position.

We use Path, however, when the textblock positions change, the path will off (not connect to) two textblocks.

What control we should use in this case? thx!


How to save formatting from a multi-line text box into SQL 2005


Hi Everyone,

I have a web form that has a few multi-line text box controls which the user will enter lots of information in paragraphs.  How can I persist their line breaks and tabs into SQL 2005 so that when the information is retrieved on a different page; the line breaks and formatting is preserved?

Thank you!


change the column type from single line of text to choice



I have created a calendar & there is an inbuilt column location that is single line of text, I want to change from single line of text to choice, but i don't see the option & I am not able to delete the Location column. is there any way to delete the column or change the type from single line of text to choice.


Thanks in advance  

How do you change the width of a multiple line of text box on a custom list form?




I have a custom list that has been added using SharePoint Designer to a web part page as a custom list form (Insert - SharePoint controls.)

The list has many single lines of text and one multiple line of text.

The multiple line of text is too wide - I need to make it narrower but how?





Multi-Line, Rich Text Field anomaly


When a user clicks on Edit Item for a previously populated and saved List item in SharePoint Services 3.0, the "edit item page" appears but the rich-text multi-line field is blank ... until it is right clicked on in the white space of the multi-line field, then the content that had been previously saved appears.

Should the user fail to right-click in the white space of the multi-line field before saving the List item again, the content previously saved will be saved over as blank. Only recoverable by version control (if enabled for that List).Not tested on

Office XP or Internet Explorer v6.

Office Pro 2007
Internet Explorer v8
Windows XP SP3
SharePoint Services 3.0 SP2 CUAug2010

Column Setting:
Append Changes to Existing Text = NO (default)
Specify the type of text to allow = Rich Text

I was able to reproduce the issue on different desktops with different List items on different Sites for both MOSS 2007 and WSS 3.0.  Clearing the browser cache doesnt resolve it.  I've proven it to

How to delete a line from a text file using C#

Hello all

I am developing a little app where I need to monitor a file that is update by several machines.

I need to gather each line wrote by each machine so I need access to a specific line number and take that line, store it into a DB table and delete that line.

I really don't know how to delete the line without parse the information into a string variable and rewrite the file. This can lake the app because the file can contain up to 1000K lines... :-O...

Any suggestion will be appreciated.

I think I deleted the Internet...
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend