Reorder ListView by wordCount through RTF files - c#

So I have a listView that references a series of rtf files saved to my disc. When you click on a list item it will display the contents of the rtf file in a RichTextBox.
I want to implement a TextBox that will reorder the list based on the number of times the TextBox's string appears in each rtf file (ideally excluding rtfs that don't have the string altogether)
Anyone have any ideas how to approach this?

I would probably build a list of the strings along with a count, starting at 0, when you go through the files, and just increment it whenever that word is found. Then you can order your list based on the counts it gives.

Related

WPF Textbox - How to save text without the wrapping-paragraph

I load some texts from a database with different lengths into a textbox. (From 1 character to 1000 words...)
I use TextWrapping="Wrap", so if the text is to big for the width of the textbox, it will create a new line....
By saving the text, the added paragraph from TextWrapping="Wrap" will also be saved. But I don't want this. The original text shouldn't be changed in any way...
How can I display the text on a new line in the textbox without adding a "real" paragraph?
Is there a way I can determine if the paragraph was added from TextWrapping="Wrap" or if it belong to the original text?
Thanks
As #StevenRands mentioned, the source text won't be changed in any way by using TextWrapping.
It only affects the display of the text inside the TextBox.
Normally if you used text Wrapping,it wont affect the original source text.But anyways Before saving back to database you can remove the new line constants from your text box text which will give you the original text loaded from db.

C# Serialized XML not showing properly in Excel

I am currently serializing a List<SomeObject> to an XML file, which works fine...
In the SomeObject properties, one of them is a string that contains multiple items delimited by the Environment.NewLine character.
When i open the XML file using Excel, some of the cells containing that property, with a few items in them, show up fine (WrapText is set) and yet some others with more items just show up as a string of # signs.
Is there a way to properly show the property's contents with the new lines in there so that Excel displays them correctly, while retaining the original XML? I mean, is this a Serialization issue, or a display setting in Excel i've missed?
The only way i was able to get the text to display properly, was to highlight the entire column in excel, and set the format to Custom -> 0 ... otherwise, in its original format of Text, i only get # signs...
Did you check to see if the XML document was formatted correctly? Because infinite #################### in a cell usually means something is either formatted incorrectly or Excel doesn't understand its type. For example, Excel can't do negative time so subtracting Earlier Date from Later Date = infinite #######. If you hover your mouse over the cell, it may tell you what the issue is.

Copying Data with Skipped Columns From Excel and Pasting into DataGridView

I've managed to copy from excel and paste it into a datagridview in C#. But when I hold down ctrl, select columns that aren't adjacent to each other, copy and paste into datagridview - all the columns in between were also pasted. Is there a way around this without actually opening the Workbook?
Current implementation simply retrieves Clipboard.GetDataObject().GetData, formats that into a string and delimit by tab.
Unfortunately excel just copies everything not just your selected columns for outside world. You can view what is copied to the clipboard using a clipboard viewer (I've used Free Clipboard Viewer). I've created a worksheet with following
1,2,3,4,5,6
1,2,3,4,5,6
1,2,3,4,5,6
1,2,3,4,5,6
and selected and copied columns 2, 4 and 6. clipboard viewer shows me what I've copied not three columns but all columns from 2 to 6 (actually Sheet!C2:C6).
You can always open excel using interop or 3rd party component and get what you need and paste it manually which I had to do for converting a grid to excel like grid. I manually parsed comma separated values and set the cells individually.
edokan is right when he says that the middle columns are also copied. Is there a setting in Excel which can prevent that? NO.
However here is the simplest way to do achieve what you want.
Before copying Delete unnecessary columns. Then copy and paste. Once done you have two options
Close the Excel file without saving
Press CTRL + Z to undo.
If you want a Code solution then yes there is a possibility. Create a VSTO Add-In. What this Add-In will do is copy the relevant columns to clipboard. Not the same as CTRL + C

Underlining Cell contents including leading blank spaces in iTextSharp

Currently i'm generating a PDF using iTextSharp in ASP.Net.
One of a field of variable lenght needs to be underlined. Actually in the output file the particular field is shown with lines (as in a ruled notebook).
For example, the field has been allocated 10 lines, so that the user can fill-in depending upon the requirement he has or may be left blank. But, now after automation, data will be fed by the user, which will be later generated as a PDF file, and this particular field is of variable length.
Is there a way i can underline the leading spaces of the field, say only 500 out of 1500 chars width is filled and rest 1000 chars can be underlined. Is there any way i can achieve it with iTextSharp.
i tried it by appending underscores to the actual data (while retrieving it from DB) and underlining the text data by assigning the underline property to the chunk class, but didn't help.
Thanks for any pointers/advise/suggestions
Download http://www.manning.com/lowagie2/samplechapter2.pdf and take a look at the figures in section 2.2.6. Is that more or less what you're looking for? In that case, you need to use a LineSeparator as described in that section.

c# listbox item size limit

When I add an item to a listbox in c#, if the string is > 4680 characters it displays as a blank line. I can still access the entire string from within the program.
Did I run up against a limit or am I doing something wrong?
The limit of text in a textbox is 64 KB worth of text. Here ya go.
displaying 4680+ characters for a single list item is not useful for the end user. You need to truncate the text or find another way to reference the text that is more user friendly.

Categories

Resources