formatting

Combining Word Documents Without Losing the Individual Formatting

The Word documents I am trying to combine all have Headers and Footers, and I'm trying to combine them into one file while keeping the individual formatting of each document intact. I am using Word 2003 (XP Pro). I have tried a few different approaches already like placing the cursor in the Master document where I want to insert anothe...

Keep formatting of textbox after a postback?

I am building a HTML scrubber basically an internal tool for scrubbing a problematic html page. I am building the tool as a web app using ASP.NET 3.5. It consists of a button and two multiline textboxes. I am programming it so you paste in the HTML you want scrubbed into the top box. Hit the button and the scrubbed HTML shows up in t...

WPF: Display a bool value as "Yes" / "No"

I have a bool value that I need to display as "Yes" or "No" in a TextBlock. I am trying to do this with a StringFormat, but my StringFormat is ignored and the TextBlock displays "True" or "False". <TextBlock Text="{Binding Path=MyBoolValue, StringFormat='{}{0:Yes;;No}'}" /> Is there something wrong with my syntax, or is this type of ...

Formatting generated C# code

Duplicate C# to format (indent, align) C# properly I am generating a bunch of code and would like it's initial output (pre ctrl+K, Ctrl+D) to look reasonable. Managing indents is a royal pain and there has to be a utility or class out there I can embed inside of my code generator. I am embedding this into a VS add-in and in a ...

Is there a truly safe formatting library for C?

Bearing in mind the answers given to a question about a safer formatting library for C, I'm wondering whether there is a safe C formatting library? What I mean is: there's no possibility to mismatch the format string from the arguments there's no possibility to crash by passing the wrong type there're no platform-dependent aspects P...

Converting a java System.currentTimeMillis() to date in python

Hello, I have timestamp in milliseconds from 1970. I would like to convert it to a human readable date in python. I don't might losing some precision if it comes to that. How should I do that ? The following give ValueError: timestamp out of range for platform time_t on Linux 32bit #!/usr/bin/env python from datetime import date prin...

Auto resize columns based on char count

I am trying to figure the best way to programmatically re-size table column headers in ReportViewer. Basically, my current resolution is the following: ColumnWidth = HeaderCaption_CharacterCount * 0.32 Where 0.32 is an estimated width of a typical character using my current font size. The issue is that the width leaves a lot of white...

Format Text from a Textbox as a Percent

I have a numeric value in a Textbox that I'd like to format as a percent. How can I do this in C# or VB.NET? ...

Proper currency format when not displaying the native currency of a culture

What is the proper way to format currency if you are formatting a currency that is not the native currency of the current culture? For example, if I am formatting US Dollars for a fr-FR culture do I format it like a en-US culture ($1,000.00) or as an fr-FR culture but changing the Euro symbol to a US Dollar symbol (1 000,00 $). Perhaps ...

Setting Property for Percentage Format ASP.Net

Applogies for what I have no doubt is a noob question. I display several percentage values in a Grid View in ASP.Net I want to be able to set the NumberFormatInfo.PercentPositivePattern Property which I think I have to bring in a Globals "property" to be able to adjust? from its Default 0 to 1 This is the property I need to adjust h...

Howto disable password request on file creation on newly formatted hard disk

I have just formatted an external hard disk using this command: $ sudo mkfs -t ext3 /dev/sdc1 However, once this is done, whenever I want to create a directory or file in this hard disk, it always ask for password (i.e. permission requirement). Is there a way I can disable that? Note that I can't format the partition with mkfs unles...

Best way to represent format for presentation of cells in a grid?

I am building a dynamic reporting feature for a client. They want to create new stored procedures, and have them correspond to new reports. We are using T-SQL and each cell in a grid/report can have its own formatting and/or functionality. I'm looking for a format specification to identify presentation, color and conditionals for data.....

How do I format a double to currency rounded to the nearst dollar?

Right now I have double numba = 5212.6312 String.Format("{0:C}", Convert.ToInt32(numba) ) This will give me $5,213.00 but I don't want the ".00". I know I can just drop the last three characters of the string every time to achieve the effect, but seems like there should be an easier way. ...

Why does Visual Studio's Format Document tool put heading tags over two lines?

So if I have a HTML heading like this <h2>A Heading</h2> and I run Edit -> Format Document it ends up looking like this <h2> A Heading</h2> why is this? It doesn't do it to other block elements, but it does do it to other inline elements (eg <label>). Update: To clarify, I mean why is this the default, not where are the setti...

Why don't IDEs support dynamic formatting?

Given all the holy wars surrounding various code formatting styles, and many companies' strict formatting requirements, why don't IDEs allow dynamic reformatting of code? By that I mean have the IDE format the code the way the user wants it every time, and save the code without any formatting at all. (Well maybe line breaks so that diffs...

how do I elegantly format string in C++ so that it is rounded to 6 decimal places and has extra '0's or '9's trimmed

How do I write a function that formats a string with decimals digits, without trailing 0's or unnecessary 9's? Given that decimals is 2, here's what I expect: 0.999 -> 1.0 0.99 -> 0.99 1.01 -> 1.01 1.001 -> 1.0 123 -> 123.0 0 -> 0.0 0.1 -> 0.1 (negatives as you'd expect) Here's what I have so far, but it's pretty ugly code. Is ther...

Calculate text height based on available width and font?

We are creating PDF documents on the fly from the database using PDFsharp. I need to know the best way to calculate the height of the text area based on the font used and the available width. I need to know the height so I can process page breaks when required. ...

formating data in php

What I need to be able do is format data in a variable, like so: format: xxx-xxx variable: 123456 output: 123-456 The problem is I need to be able to change the format, so a static solution wouldn't work. I also like to be able to change the variable size, like: format: xxx-xxx variable: 1234 output: 1-234 All ideas are welcome! Th...

Numeric Format String : double to time

Hi I have a double value in seconds and i would like to use a Numeric Format String to display it as mm:ss or hh:mm:ss. Is this possible? Havent found anything about it on MSDN? The reason is that we use a Telerik Chart that displays our data and since I cant change the uderlying format I have to hook the format string into their char...

Paypal date formatting: what is "HH:MM:SS DD Mmm YY, YYYY PST"?

I'm looking at the Paypal IPN docs, and it says the datetime stamps of their strings are formatted as: HH:MM:SS DD Mmm YY, YYYY PST So year is specified twice? Once in double digits, and another with 4 digits? This looks bizarre. ...