Click here to Skip to main content
15,868,016 members
Everything / Formating

Formating

formatting

Great Reads

by Athari
CsConsoleFormat library for .NET - Formatting in Console using modern technologies
by Mark Pelf
Beginner’s tutorial on PE format, with illustrations
by wborgsm
How to draw muliline formatted text on a System.Drawing.Graphics object.
by BernardIE5317
On certain occasions, Visual Studio does not indent as intended so here is an awk program which does the trick.

Latest Articles

by Mark Pelf
Beginner’s tutorial on PE format, with illustrations
by honey the codewitch
A handy code snippet that can set indentation levels while rendering multipart documents with a TextWriter
by BernardIE5317
On certain occasions, Visual Studio does not indent as intended so here is an awk program which does the trick.
by Athari
CsConsoleFormat library for .NET - Formatting in Console using modern technologies

All Articles

Sort by Score

Formating 

3 Mar 2018 by Athari
CsConsoleFormat library for .NET - Formatting in Console using modern technologies
10 Mar 2023 by Mark Pelf
Beginner’s tutorial on PE format, with illustrations
22 Aug 2012 by wborgsm
How to draw muliline formatted text on a System.Drawing.Graphics object.
22 Jan 2014 by Sergey Alexandrovich Kryukov
The best algorithm for storing passwords is not storing any passwords; this is unsafe and absolutely not needed for authentication.Surprised, disagree? Please see my past answers:i already encrypt my password but when i log in it gives me an error. how can decrypte it[^],Decryption of...
10 Mar 2011 by Sergey Alexandrovich Kryukov
Here is the answer with the code sample: http://msdn.microsoft.com/en-us/library/5hh873ya.aspx[^].For more flexible option, see this: the class System.Globalization.DateTimeFormatInfo and the sample code provided:...
6 Sep 2011 by Espen Harlinn
Take a look at DirectShow MediaPlayer in C#[^]The last three links at the bottom of the article is quite good.Best regardsEspen Harlinn
21 Sep 2011 by AspDotNetDev
The read-only attribute and similar attributes are part of the meta-data for the file. They are stored by the operating system and cannot be found in the file data.Text files don't typically actually have an end of file character (or sequence) stored in the data. You know where the end of...
17 Jan 2017 by OriginalGriff
You would have to say:if (dog != "cat" && dog != "cow")Orif (!(dog == "cat" || dog == "cow"))
3 Aug 2021 by BernardIE5317
On certain occasions, Visual Studio does not indent as intended so here is an awk program which does the trick.
21 Dec 2010 by Luc Veronneau
A JavaScript class used to help in formatting and parsing numbers when parseInt and parseFloat are not enough
10 Mar 2011 by William Winner
if the formats here: Standard Date and Time Format Strings[^] aren't giving you the results you expect, then you may need to check your culture settings.
5 Sep 2012 by Mario Majčica
This should do:string a = @"If I had to live my life without you near me The days would all be empty The nights would seem so long With you I see forever oh so clearly I might have been in love before ...
22 Dec 2015 by George Jonsson
You can try this JavaScript highlighterhttp://alexgorbatchev.com/SyntaxHighlighter/[^]Quote:SyntaxHighlighter is a fully functional self-contained code syntax highlighter developed in JavaScript. To get an idea of what SyntaxHighlighter is capable of, have a look at the demo page[^].
15 Apr 2016 by Industria Virtual
Joinning a a Text Box and a Select Combo in a HTML Form.
2 Feb 2011 by M@dHatter
PHP Magic String Builder with Append Format.
27 Mar 2011 by Wendelius
Try changing the BodyEncoding[^] property.
17 Dec 2011 by DaveAuld
After doing various searches on the big G, the best option might be to email the manufacturer or the guys here; http://www.tomovision.com/download/download.htm[^] They apparently have a file viewer that can read the format.
18 Jan 2012 by Sergey Alexandrovich Kryukov
I think this would be easier:Define the Console methods you use with exact same name and signatures://[EDIT...]internal class UiConsole { internal UiConsole(TextBox sink) { this.Sink = sink; } internal string void WriteLine(string value) { /* this is easy */} ...
9 Jul 2012 by Matt T Heffron
This is an alternative for "Custom String FormatWith using Reflection"
16 Nov 2012 by Espen Harlinn
ImageMagick would do the trick, have a look at:ImageMagick: Convert, Edit, Or Compose Bitmap Images[^] and Magick++ C++ API[^] - it's a great package.Best regardsEspen Harlinn
16 May 2013 by Shweta Lodha
Some tips on Windows Phone Apps
4 Dec 2014 by DamithSL
this.TimeText.Text = Time.ToString("hh\\:mm\\:ss\\:ff");
23 Feb 2016 by Dave Kreskowiak
There is nothing built into Visual Studio that will turn that off and the edit document formatter does not apply indenting to directives. I don't know of a plugin that puts the indenting in or maintains it.
30 Mar 2016 by RickZeeland
Not exactly C# 6, but simple:string x = "3";Console.WriteLine(x.PadLeft(2, '0'))
10 Oct 2019 by LillyLeaf
I need to make a table that well somewhat look like the one on the bottom. I am not exactly sure what is wrong with my coding. I get odd errors when I execute it. Please help me! Thank you so much for taking the time to read through my mess. :) errors: Exception in thread "main"...
12 Jul 2022 by 0x01AA
See also my comment to the question. If I understand your request correctly, something like below should do the job: DateTime DateStart = new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, dateTimePicker1.Value.Day, 12, 0, 0);
28 Feb 2011 by Sergey Alexandrovich Kryukov
Q1: Yes, of course. How are the execution flow and stack frames (something calling mechanism based on) related to the output stream? They are unrelated. The only problem can be supportability and coding style. If all three actions are performed in two three different function is may be too much...
10 Mar 2011 by xiaobaino1
1 .String.Format("{0:dd/MM/yyyy}", DateTime.Now)26/09/20092. String.Format("{0:MM/dd/yyyy}", DateTime.Now) 09/26/20093 . String.Format("{0:dd/MM/yy}", DateTime.Now) 26/09/094. String.Format("{0:t}", DateTime.Now) 12:22 PM5.String.Format("{0:F}",...
5 Apr 2011 by Henry Minute
In case you haven't already seen it, you might find this[^] useful.Also there is a nice Article here on The Code Project which may give you some ideas: Reading Image Headers to Get Width and Height[^].Hope this helps.
17 Dec 2011 by Amir Mahfoozi
As I understood its format is DICOM so try to analyze this open source software :http://www.osirix-viewer.com/[^]Or you can convert it to a wellknown format :Converting a DICOM image to a common graphic format and vice versa with DCMTK and...
17 Jan 2012 by OriginalGriff
Why?Replace it with string.Format:Console.WriteLine( "{0} (quantity {1}) was replaced by {2}, (quantity {3}).", item.Description, item.Quantity, replacement.Description, replacement.Quantity);myTextBox.Text = String.Format( "{0} (quantity {1}) was replaced by...
17 Jan 2012 by RDBurmon
I think you are looking for this StringBuilder str=new StringBuilder();str.AppendFormat("{0} (quantity {1}) was replaced by {2}, (quantity {3}).", item.Description, item.Quantity, replacement.Description, ...
1 Feb 2012 by Catalin Serafimescu
Have you tried Binding::Format and Binding::Parse ? http://msdn.microsoft.com/en-US/library/system.windows.forms.binding_members(v=vs.80).aspx[^]
7 Mar 2012 by OriginalGriff
That is because '\n' means nothing to the browser - it is just whitespace which can be removed. Consider using string.Replace to change it to an HTML newline:dr.fContent = txtContent.Text.Replace("\n", "");
4 May 2012 by VJ Reddy
Write a method to fix the start index for writing the data to the excel sheet as shown below://Declare a DataRow for holding the previous row//accessible for the getStartIndex methodDataRow previousRow;//In the following code set C to the start index //as obtained from...
5 Sep 2012 by D-Kishore
Hi, browse these links,http://www.dotnetfunda.com/articles/article11.aspx[^]http://csharp.net-informations.com/string/csharp-string-split.htm[^]http://www.dotnetperls.com/split[^]
17 Oct 2012 by Sergey Alexandrovich Kryukov
Something is fundamentally wrong with your approach to work in general. Was it so difficult to look at the MSDN help page and see the right spelling? Well, take a look now:http://msdn.microsoft.com/en-us/library/system.string.substring.aspx[^].Please, no offense: what you really need to...
11 Dec 2012 by Adam R Harris
You need to format the column in excel. have a look at this: http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/fdc6cfb5-e7cc-466f-95f0-d8cd29f49d2d/[^]
19 Apr 2013 by CHill60
There are loads of tools ...Try this opensource option http://sourceforge.net/projects/fsqlf/[^]and Pinal Dave has a blog on the very subject http://blog.sqlauthority.com/2007/05/20/sql-server-sql-code-formatter-tools/[^]Google will present you with several (free) on-line tools too.
7 Nov 2013 by kankeyan
http://www.sql-server-helper.c...
21 Dec 2013 by Peter Leow
Your formula for standard deviation seems odd, you may want to check with google. However, that is not issue here.You should only do the formatting on the return double value in the calling method not in the called method. See the changes below, I am assuming you want double with 2 decimal...
23 Jan 2014 by Maciej Los
You don't need to format anything! Date should be a date, not string!If you want to insert data into SQL database, you should know the format which is used by MS SQL server. Have a look at SET DATEFORMAT[^] command.Finally, you should use stored procedure[^]:USE DataBaseName;CREATE...
29 Jan 2014 by Yogesh Potdar
You can check by trying to deserialize the object JsonConvert.DeserializeObject(YourResult)
7 Jun 2014 by Kornfeld Eliyahu Peter
It's not exactly clear to me what went wrong with you, but I think that the base of your approach is wrong...You should not use try...catch - it's a very expensive writing...Do use Int32.TryParse[^] to check if the value is numeric...
8 Jun 2014 by OriginalGriff
Why not do it properly, instead of using exceptiosn as part of your "normal operation" processing?int guess;if (!int.TryParse(textbox_guess.Text, out guess)) { MessageBox.Show("You must enter a number!"); }else { if (guess > number...[edit]Indentation reverted -...
7 Jun 2014 by DamithSL
problem is after you get exception you are not exist the function. then other validations will perform and you will get some other messages as well.try{int guess = Convert.ToInt32(textBox_guess.Text);}catch(FormatException ex){ MessageBox.Show("You must enter a number!"); ...
7 Jun 2014 by Abhinav S
Convert.ToInt does not check if an input is really an integer or not.To check type, use a Int.TryParse.To be cautious about cultures, go through Check If A String Value Is Numeric[^].
24 Jul 2014 by SRS(The Coder)
The simplest logic you can refer is as per this method i have displayed below :-private string GetFormattedString(string strInput) { string strOutput = string.Empty; if (strInput.Contains(".")) { string[] arrInpt =...
24 Jul 2014 by Sharmanuj
Hi Check this simplest code to format the string. Hope this will help you to achieve your output.private string FormatString(string inputString) { string formattedString = string.Empty; try { string[] arrInput =...
4 Sep 2014 by thatraja
Try thisGridView - Add Padding to Cells with CSS[^]
28 Nov 2014 by OriginalGriff
Try this: double d = 12.345678; Console.WriteLine("{0,8:000000.00}", d); Console.WriteLine("{0}", d.ToString("000000.00"));
14 Dec 2014 by Shweta N Mishra
check thisDeclare @date1 Datetime='Dec 15 2014 08:00 AM'Declare @date2 Datetime='Dec 15 2014 06:30 PM'select DATEDIFF(MINUTE,@date1,@date2)/60.0
14 Dec 2014 by OriginalGriff
Ignore the hours: do the difference in minutes only, and convert that to floating point hours and you will get your result.SELECT *, CAST(DATEDIFF(minute, login_time, logout_time) AS DECIMAL) / 60 AS Worked FROM MyTable
14 Dec 2014 by /\jmot
try..SELECT *,CAST((Datediff(MINUTE,login_time,logout_time)/60) as decimal(18,2)) AS [TotalHrs_Worked] FROM table_DTR WHERE CONVERT(VARCHAR(10),log_date, 101) BETWEEN '09/01/2014' AND '11/30/2014'
17 Jun 2015 by Richard Deeming
Internationalization and localization of javascript code isn't particularly easy. The parseFloat method doesn't handle different culture settings; it always assumes that "." is the decimal separator, and "," is the thousands separator.The options you're passing to the toLocaleString...
15 Apr 2016 by OriginalGriff
Any characters which are not used by the scanf format will remain in the buffer and will by "pulled" next time you call any method which retrieves characters from the same stream. I.e. the behaviour you have seen is universal.Similarly, if you use scanf to extract an integer from "123ABC"...
17 Jan 2017 by Matt T Heffron
If you're going to need to do this frequently, especially if there are more than just a couple of items then you should make a function that does this: public static bool IsOneOf(string s, params string[] many) { if (many == null) throw new ArgumentNullException("many"); ...
10 Oct 2019 by Catey Category
Reading the exception that your code throws shows it has trouble converting your double into a '%d'which is a decimal integer. Makes sense, a double isn't an integer. See this tutorial from Oracle. If I replace; System.out.printf("%4d%2f", equation); with: System.out.printf("%.1f ",...
24 Apr 2022 by OriginalGriff
We can't tell - we don't know which line is causing the problem, but if it's not the ReportDate then it's likely to be this one: $"{_options.Value.IsoQueryParameterName = totalRequest.CountryIsoCode}"; Since the error is an in enum conversion...
13 Mar 2023 by Graeme_Grant
one way of doing it: Dim message = "Our society, 01:12:15:14 the whole country" Dim result(message.Length) As Char Dim position As Integer = 0 For i As Integer = 0 To message.Length - 1 If "1234567890:".Contains(message(i)) Then ...
13 Mar 2023 by OriginalGriff
Use a Regex: Imports System.Text.RegularExpressions ' Regular expression built for Visual Basic on: Tue, Mar 14, 2023, 07:29:32 AM ' Using Expresso Version: 3.0.4750, http://www.ultrapico.com ' ' A description of the regular expression: ' ...
23 Sep 2010 by Sandeep Mewara
Go ahead and write it. Anyone stopping you? :doh: Here is what is expected by enquirers:1. TRY first what you want to do!2. Formulate what was done by you that looks like an issue/not working. Try them and tell if you face issues. Members will be more than happy to help like this.
8 Jan 2011 by sytools
Convert OST into PST Software is corrupt OST file which effectively convert OST file to PST file which become inaccessible due to virus attack, server crash, and data base corruption. The Recover OST File is successfully recover your Outlook contacts with complete email, attachments, contacts,...
8 Jan 2011 by Espen Harlinn
Where I live ost means cheese, and pst is an acronym for "Politiets sikkerhetstjeneste" - or the Police Security Service. Nice to know that someone can convert a cheese into a security service :laugh: Not much of a question though :suss:Espen Harlinn
24 Jan 2011 by Mohd Wasif
Hi All,I have string in format 24/01/2011 in day/month/year format.I want to convert it into date time format.In asp.net I did something like this:DateTime Dob = Convert.ToDateTime(TextBox2.Text);but it's showing as string is not in date time format.Now I am giving complete...
7 Feb 2011 by Fatih P.
Here is the one i wrote sometime ago/* ---------------------------------------------------------------------------- * Teknober.com - All rights reserved * ---------------------------------------------------------------------------- * File Name : TStringBuilder.php * Section ...
17 May 2011 by henujava
I am making an application of capture video,the frame format of my camera is NTSC.My programm only can capture PAL video.What i can do to modify the frame format of my camera,I need use functions in driver.But,i don't know what i can do for it.Please help me in this regard.Thanks...
14 Jun 2011 by Steve Roberson
This version treats the input string as an indexed string. The code is a little shorter.private string createDisplayText(string propertyName){ if (String.IsNullOrEmpty(propertyName)) { return String.Empty; } StringBuilder builder = new StringBuilder(); ...
6 Sep 2011 by Jackie00100
Hi everyone.Me and a group on my university is about to make a "smart/inteligent" jukebox player in C# and we have searched alot on the internet to find some sort of references that can play a number of difference music formats but also is easy to use, but yet no one of us have found...
7 Sep 2011 by Jackie00100
I've found a kinda okay good solution by using Microsoft.DirectX.DirectSound kinda easy to use, and have alot of the features i need and also it can play multiple sounds at once so this is yet the best solution but ty to you harlinn anyway.
12 Sep 2011 by MohammadIqbal
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { try { if ((this.dataGridView1.Columns[e.ColumnIndex].Name == "STATUS")) { if...
21 Sep 2011 by David W. Young
Hello, I have a quick question concerning file attributes. I am only talking about general file attributes such as read only, etc. More to the point, are these attributes stored within the file itself, and if so, what is the format that they are stored in? Personally, I'm thinking that they are...
17 Dec 2011 by hassan vaezi
Hi everyone,I have a file that has a new format and i can't read it by .NET.The Extension of the file is *.VOL and it's about Ultrasound Image systems. (KRETZFILE 1.0)Would you please help me?
1 Feb 2012 by spitfire_ch
I am looking for a way to display other data in a MaskedTextBox than the data it is bound to (DataTable).More specifically: The DataTable contains a DateTime column (DateOfBirth). Whenever the year is 1900, I would like to display it as empty in the MaskedTextBox while keeping it in the...
7 Mar 2012 by bala.vanchi
Hellow, Generally, textbox won't allow to save formatted text. rather use richtext box control which will allow you to enter the formatted text the retrieve it back. but still you want to do it in a formatted way.. you have enter it as html tags like Text and so on..
7 Mar 2012 by Ganesan Senthilvel
Instead of TextBox, you can use RichTextBox. Refer CodeProject article at: C# - Formatting Text in a RichTextBox by Parsing the Rich Text Format (RTF)[^]
15 Mar 2012 by Dionis Matos
Hello allI'm having issues with the datetimepicker control in VB.NETWhen i'm debugging the value it takes its only the hour. I have short date format. Any ideas why this control is doing this?Thanks in advance!Here is my code:f.desde = dtpDesde.Value.Datef.hasta =...
15 Mar 2012 by Ganesan Senthilvel
Use dateTimePicker1.Value.Date to get the Date part of this DateTime value.Do notice though, if you mean to parse into strings, that using dateTimePicker1.Value.Date.ToString will result with the "16/03/2012 10:10:10" string, while using something like MyString =...
16 Mar 2012 by Member 8734651
Hello everybody ,i have a problem with format , i need to change format of column when i get records from my bank(access) , i use code like this but didnt word :da.SelectCommand = New OleDbCommand() With da.SelectCommand .Connection = my_con ...
16 Mar 2012 by siavashebrahimi
hello everybody,i have problem with DefaultCellStyle in datagridview,i have 3 column in my bank(Access) and i want when those records come to my datagridview change their format , for example their format is 12000 but i want to change their format in datagridview like 12,000. this is...
18 Mar 2012 by ProEnggSoft
As seen from the images at URL specified in your question, the formatting is required in second Column. So, the Column Index will be 1.Set the Format property as belowMe.DataGridView1.Columns(1).DefaultCellStyle.Format = "#,0"
4 May 2012 by pmcm
Hi, in the data being exported from datatable i'd like to hide some particular column data if it is duplicated on the previous row for example:Timesheet Job EmployeeName TimeOn TimeOff Group Qty Total4/5/12 123 Joe 630 900 Test 45 90 4/5/12 123 Joe ...
4 May 2012 by pmcm
VJ Reddy - i'd like to thank you for your help, but i solved this by doing the following:int introwCount = 1; foreach (DataRow dr in LIPSdb.dsResults.Tables["tbl_Daily_Timesheet"].Rows) { gintRow++; //write out the row data ...
8 May 2012 by ashishgr8
1) I have a project in windows C#, is there any method to customize the date format of DateTimePicker control on all formas in whole project at run time,as per the client requirement ,eg if client wants MM/dd/yyyy or dd/MM/yyyy2)can we change date format of existing data in SQL...
8 May 2012 by Mehdi Gholam
This can be done at the windows level via Control Panel->Date Time->Change Calendar Settings.So you don't have to do anything in your application.
5 Sep 2012 by duonglg
Hello everybody!In project C#, I have a problem, please everybody help me!I have a string that i will enter to textbox, example:"If I had to live my life without you near meThe days would all be emptyThe nights would seem so longWith you I see forever oh so clearlyI might have...
8 Dec 2019 by zlristovski
I have C# who communicate with dot matrix printer on LPT1 port. I want to send control codes on the printer, but when I am sending the codes, printer is not responding, it answers only when I send FF code. I want to send this code ESC EM 82, but I don't know how to format it, FF I am sending hex...
10 Sep 2012 by Herman<T>.Instance
just google: https://www.google.nl/search?hl=nl&q=c%23+esc+codes+epson+printer[^]and find a MicroSoft reference like http://support.microsoft.com/kb/322091[^]
16 Nov 2012 by YvesDaoust
Hi all,I am looking for a free portable library to read images files in the most common formats from a C++ program: Bmp, Png, Tiff and Jpeg are a must.The library must be usable under Windows / Visual C++ as well as Linux Ubuntu / gcc (Eclipse). Can be precompiled or source code.I...
11 Dec 2012 by Naveen Nallavelli
I am trying to export some values to Excel. I am able to export values like 1.23, 5.45,9.25 successfully with decimal values by specifying dataFormatString = {0:N2}. But the same is not working when I export 0.00, the decimal values 00 after the period are removed . So I am just seeing '0'...
12 Jan 2013 by navidsoft
Hello every body I cunstructed an EDITOR seems to windows Notepade for my software to bring out special informations and show them to the user. the user has ability to make some changes like Font size change or bold some where in text by the editor and save in SQL and then print the text...
12 Jan 2013 by cocis48
The report viewer already has the ability to export in various types (excel, pdf and word) automatically,but it does not allow the user to change the data, we don't know what your Editor is doing with the text, only you can answer that question. 'Esc' chararaters require special handle logic in...
7 Feb 2013 by Abdulmateen50
To display a number with its associated currency symbol and the appropriate number of decimal places we use the currency character “C” or “c”, like:Console.WriteLine("{0:C}", 1.2");The number 1.2 appears in the output like this: $1.20.my question is what does "0" indicates in {0:C}??
16 Feb 2013 by H.Brydon
These features of COBOL are built into the compiler, and are not generally available in other languages (with some exceptions: PL/I, ADA).You flagged "C" as your language of interest. These features are not built into the C language, but you might be able to find a library somewhere that...
19 Feb 2013 by lsatenstein
Adding commas using sprintf(), was no challenge. I have tested it with positive and negative numbers between one digit and 16 digits.I need to remove the debugging code and post it here in the next day or two.I have almost completed the formating using the Cobol Picture clause. The...
21 Feb 2013 by Maciej Los
Ali_100, start here: Data Types (C#)[^]. More here: Date Data Type[^]Remember: Date is a date, string is a string!If you want to store dates, you need to use date not string data type. Of course, you can always parse date from string, as is described here:...
22 Feb 2013 by Ali_100
I did it by the linkClick
29 Mar 2013 by S R JHALA
LblExpirydate.Text = dataReader(0).ToString("d")