Click here to Skip to main content
15,911,711 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# and mobile phone ? Pin
Saksida Bojan24-Feb-10 19:22
Saksida Bojan24-Feb-10 19:22 
GeneralRe: C# and mobile phone ? Pin
ddayse24-Feb-10 19:24
ddayse24-Feb-10 19:24 
GeneralRe: C# and mobile phone ? ==> Thanks ddayse and Bojan Pin
Nematjon Rahmanov24-Feb-10 19:46
Nematjon Rahmanov24-Feb-10 19:46 
QuestionHow to create a TIF or PDF file with a structured layout from a data file? Pin
neualex24-Feb-10 16:52
neualex24-Feb-10 16:52 
AnswerMessage Closed Pin
24-Feb-10 18:52
stancrm24-Feb-10 18:52 
GeneralRe: How to create a TIF or PDF file with a structured layout from a data file? Pin
neualex25-Feb-10 0:27
neualex25-Feb-10 0:27 
QuestionRead & Display a huge text file in textbox Pin
dengboo24-Feb-10 16:45
dengboo24-Feb-10 16:45 
AnswerRe: Read & Display a huge text file in textbox Pin
AspDotNetDev24-Feb-10 17:41
protectorAspDotNetDev24-Feb-10 17:41 
Use your own scrollbars (HScrollBar, VScrollBar). Set the Maximum on the HScrollBar to the size of the textfile / 80 (or whatever average line length you think would be appropriate). When somebody scrolls, you can approximate where they are in the file and load up that text into a fixed-size TextBox. When you change the text as they scroll, you'll want to remember the position of the caret and the selected text so you can reapply them after you change the text. Also, intercept key presses for up/down/left/right/page down/page up/etc so you can implement those functions yourself. For the HScrollBar Maximum, default it to 80. Like the VScrollBar, you should use the position of the HScrollBar to scroll through the fixed-size textbox (which really means changing the text in the textbox.

In a background thread, scan through the entire text file to find line breaks and actual line widths and the number of lines in the file. Store the positions of the line breaks in a file (text file, binary file, SQL Server CE file) so that you can get information about a given line by looking at that file (this helps you avoid using RAM). Once you have scanned the entire file, you can adjust the Maximum for the HScrollBar and VScrollBar to the actual values (i.e., the number of lines in the file and the number of characters in the widest line). Having the offset of the line beginnings stored in a file will allow you to instantly determine where in the text file the data is for a given line number. This will allow you to create perfect scrolling that is virtually instantaneous (the scrolling will be instantaneous and approximate up until you have loaded everything from the text file).

It gets a little more complicated if you want to allow the user to make edits. In that case, you'd probably want to asynchronously load each line of the file into a SQL Server CE database. Whenever an edit is made, you'd have to intercept it (e.g., via keypress) and made the corresponding edit to that line in the database. If you want to save the file, you'd then store each of those lines in the database back to the text file. Or, if you want all edits to immediately be saved to the text file, you could just avoid the database altogether.

There are other details you'll probably have to worry about, but I trust you can figure them out. Note that SQL Server CE has a maximum size of about 4GB. If you need larger than that, you can choose another database format or use your own file format.
GeneralRe: Read & Display a huge text file in textbox Pin
dengboo24-Feb-10 18:50
dengboo24-Feb-10 18:50 
AnswerRe: Read & Display a huge text file in textbox Pin
Luc Pattyn24-Feb-10 17:55
sitebuilderLuc Pattyn24-Feb-10 17:55 
GeneralRe: Read & Display a huge text file in textbox Pin
AspDotNetDev24-Feb-10 18:01
protectorAspDotNetDev24-Feb-10 18:01 
GeneralRe: Read & Display a huge text file in textbox Pin
Luc Pattyn24-Feb-10 18:05
sitebuilderLuc Pattyn24-Feb-10 18:05 
GeneralRe: Read & Display a huge text file in textbox Pin
AspDotNetDev24-Feb-10 18:10
protectorAspDotNetDev24-Feb-10 18:10 
GeneralRe: Read & Display a huge text file in textbox Pin
Luc Pattyn24-Feb-10 18:24
sitebuilderLuc Pattyn24-Feb-10 18:24 
GeneralRe: Read & Display a huge text file in textbox Pin
AspDotNetDev24-Feb-10 18:30
protectorAspDotNetDev24-Feb-10 18:30 
GeneralRe: Read & Display a huge text file in textbox Pin
dengboo24-Feb-10 18:38
dengboo24-Feb-10 18:38 
GeneralRe: Read & Display a huge text file in textbox Pin
Luc Pattyn25-Feb-10 2:24
sitebuilderLuc Pattyn25-Feb-10 2:24 
AnswerRe: Read & Display a huge text file in textbox Pin
Som Shekhar24-Feb-10 20:09
Som Shekhar24-Feb-10 20:09 
GeneralRe: Read & Display a huge text file in textbox Pin
AspDotNetDev24-Feb-10 21:51
protectorAspDotNetDev24-Feb-10 21:51 
GeneralRe: Read & Display a huge text file in textbox Pin
Som Shekhar24-Feb-10 22:17
Som Shekhar24-Feb-10 22:17 
GeneralRe: Read & Display a huge text file in textbox Pin
AspDotNetDev24-Feb-10 22:27
protectorAspDotNetDev24-Feb-10 22:27 
GeneralRe: Read & Display a huge text file in textbox Pin
Som Shekhar24-Feb-10 22:32
Som Shekhar24-Feb-10 22:32 
GeneralRe: Read & Display a huge text file in textbox Pin
AspDotNetDev24-Feb-10 22:34
protectorAspDotNetDev24-Feb-10 22:34 
GeneralRe: Read & Display a huge text file in textbox Pin
Som Shekhar24-Feb-10 22:36
Som Shekhar24-Feb-10 22:36 
GeneralRe: Read & Display a huge text file in textbox Pin
Luc Pattyn25-Feb-10 2:26
sitebuilderLuc Pattyn25-Feb-10 2:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.