Click here to Skip to main content
15,887,831 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 Title

Formating 

21 Dec 2013 by Wombooo
Anyone? Does anyone have any way of helping me?
23 Oct 2021 by honey the codewitch
A handy code snippet that can set indentation levels while rendering multipart documents with a TextWriter
15 Feb 2014 by kool15th
I have a application which saves date and time into sql server 2008 database, than those values are fetched within the selected time range i.e, from Date and To date. The query searches into database that if today's date lie between the selected date range, if yes than perform task.The issue...
15 Feb 2014 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
DateTime dt = this.dateTimePicker1.Value.Date;But this will also contain default time that is 12:00 AM as it is a DateTime Object.Otherwise you have to convert to string.
15 Feb 2014 by OriginalGriff
DateTime objects in .NET always have a time - they are stored as a number of milliseconds since an arbitrary point in time, so there is no way to have a DateTime without the Time unless you create a custom class.However, SQL does have a Date type which does not include the time. You could...
15 Feb 2014 by Gitanjali Singh
Try by setting CustomFormat// Set the Format type and the CustomFormat string.dateTimePicker1.Format = DateTimePickerFormat.Custom;dateTimePicker1.CustomFormat = "yyyy/MM/dd";Refer:http://stackoverflow.com/questions/1138195/get-date-from-date-time-picker[^]Hope this will work.
15 Feb 2014 by Krunal Rohit
First convert the date in string and give it a format as per your need and the convert it back to DateTime. See,String to DateTimeString MyString; MyString = "1999-09-01 21:34 PM"; //MyString = "1999-09-01 21:34 p.m."; //Depends on your regional settings DateTime MyDateTime;...
23 Sep 2010 by Milan Kumar Sah
Write a program to make a digital clock using nested for loop? :-D
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.
27 Mar 2011 by MarqW
Hi, I've a segment of code which combines the HTML signature from Outlook into an email settings (Code below).However, when the string contains accentuated characters (ie, é), the emails sent through the .NET Mail objects replace them with the "?" character. Is there anyway to retain the...
27 Mar 2011 by Wendelius
Try changing the BodyEncoding[^] property.
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.
17 Aug 2017 by ddgjgj
This is the model : e[DataType(DataType.Date)] public Nullable PublishDate { get; set; } This is the view : e @Html.DisplayNameFor(model => model.PublishDate) @Html.DisplayFor(model => model.PublishDate) ...
16 Aug 2017 by Namith Krishnan E
Try this while chaging the culture. Set newCulture as your changed culture CultureInfo newCulture = (CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone(); newCulture.DateTimeFormat.ShortDatePattern = "dd-MMM-yyyy"; newCulture.DateTimeFormat.DateSeparator = "-"; ...
17 Aug 2017 by Richard Deeming
If you want to control the format for a specific field, use the DisplayFormat attribute: DisplayFormatAttribute Class | Microsoft Docs[^] [DisplayFormat("dd-MMM-yyyy")] public DateTime? PublishDate { get; set; } (NB: DateTime? is a shorthand way of writing Nullable.) If you want to...
26 Sep 2013 by TrinityBeats
I have purchased a WP theme from Themeforest by Codestag called Shift and its a pretty easy to use and clean UI. It is mostly for blog style posts and they have created pre-made blog posts styles...For example, an "Audio" post is text and the enbedded audio file. "Video" is the video link...
22 Jan 2014 by DoingWork
I want to store Login passwords (in some format rather than original text) in SQL Database that unable or difficult to be hacked.1. What is the best algorithm for that?2. Can anyone explain how this algorithm will work for matching while matching during login ???Thanks.....
22 Jan 2014 by Christian Graus
The best thing to do is to google for articles and read up on how to use the stuff that is BUILD IN to SQL Server, instead of writing something inferior to that yourself.Basically, the best solutions actually encrypt the password, and the login code encrypts the password, and compares the...
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...
29 Jun 2015 by jindrich.babica
Binding with respect to CurrentCulture
22 Mar 2017 by Fiyaz Hasan
Know how to create a custom request/response formatter for ASP.NET Core apps
8 Jul 2016 by Member 11905879
hi, i am able to connect to my local db file .sdf directly with my winform app. but unable to do so when i am using an connstring. here is what i have tried1. using app.config filevar config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var...
8 Jul 2016 by F-ES Sitecore
You don't need the "@" at the front, so leave that bit out. The @ isn't part of the string, it is an instruction to the compiler to treat all characters as literal. It is used when dealing with paths so you don't have to escape the "\" characters.SqlCeConnection con = new...
30 Nov 2014 by Kinna-10626331
I want to transform a double get it from a slider with format "xx.xxxx" into a double with next format "xxxxxx.xx".Example if receive: 15.678934 I want to convet it in: 156789.34I checked in several places but I only find formulas to round or add ceros before or after...
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"));
30 Nov 2014 by Kinna-10626331
I don't know what I was thinking ! Lately I had to do many parsing and conversions stuff that I didn't realize that for this case the solution were simple maths!!double dconverted=mydouble*10000; d.tostring("######.##");
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...
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
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.
9 Feb 2013 by leprechauny
public class Eagle : Bird { public Eagle():base() { } public Eagle(string name, string id, double age, CategoryType category, GenderType gender, BirdSpecies birdSpecie) : base(name, id, age, category, gender) { birdSpecie =...
9 Feb 2013 by Sergey Alexandrovich Kryukov
No, there is no "mix-up". The problem is trivial. These two code lines have almost nothing in common, so the "answer" would depend on what you want to achieve. Who told you base.ToString() is supposed to do anything useful, especially in you did not override this method in your base class.To...
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}??
7 Feb 2013 by E.F. Nijboer
It referers to the variable (zero-)index in params.Console.WriteLine("{0:C} {1:C} {0:C}", 1.2, 1.5);will output:1.2 1.5 1.2Good luck!
11 Nov 2013 by Andy Bantly
An understanding of the record structure for a string record in the XLSB file format.
23 Feb 2016 by Patrick Skelton
Hi,I can almost hear the clamour of criticism from here, but I'm working alone and I have always found compiler directives much easier to read when they are placed at the same indent level as the code they are affecting. In older versions of Visual Studio, it left them where I put them, but...
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.
27 Jan 2021 by Member 10369098
I am a newbie to asp and am trying to setup a form. When I send the form I get the following error:CDO.Message.1 error '8004020d'At least one of the From or Sender fields is required, and neither was found.Here is my code:
29 Oct 2013 by thatraja
Member 10369098 wrote:CDO.Message.1 error '8004020d' At least one of the From or Sender fields is required, and neither was found.The error message clearly telling you that you didn't pass value for From/Sender fields. And I have checked your code & found that you didn't pass value for...
26 Jan 2021 by Member 14188092
In your html code, you stipulate This is indicating that the form field name for the recipient is Custemail; however, in your asp code, you mixed the potential value for that field with the form field name. objMail.To =...
12 Jul 2022 by Tinker-Bel
Hello, I have this datetime object: DateTime DateStart = dateTimePicker1.Value; Now I'd like to set the picked date to a fixed hour, for instance 12u. So the format would look like 'yyyyMMddT12mm00' This can be easily done by setting a...
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);
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...
24 Jan 2011 by Sushma_Patel
Refer this [^]
24 Jan 2011 by OriginalGriff
If you run the code you give:DateTime Dob = Convert.ToDateTime(TextBox2.Text);Then "Dob" will contain the date in DateTime format - it can't hold anything else.However, whenever you try to print it: to the console, or a label, or a textbox, or even view it in the debugger, there is an...
15 Feb 2013 by lsatenstein
How to?Cobol has an input mask format similar to the following: Using integer 345picture "99999" yields 00345 picture "zzzz9" yields 345 or even "zzzVzz" yields 3.45 "9zzzVzz" invalid (9 to the left of z)."$zzVzz" floating dollar ...
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...
22 Dec 2015 by Member 10711621
How to colour highlighting and code formatting done. while we post a question in codeproject.com forum. How colouring done only for code not for theory part. any one can explain me please. Because i want to implement too like this forum.
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[^].
22 Oct 2010 by TweakBird
Common Mistakes Made by Programmers
3 Sep 2013 by Ahmed_Mostafa
This is a useful tip for formatting numbers in C#.
12 Dec 2012 by Pranay Rana
Convert DateTime string to DateTime variable
5 Apr 2013 by bEGI23
Convert filesize (bytes) according to highest possible size scale (KB, MB, GB, TB, PB).
20 May 2015 by Jamil Isayyed
Hello Folks,I am trying to convert all internal mails (TNEF format) in exchange server to plain text.i successfully converted the body, but i couldn't convert or change the body format in the TNEF message to plain text which is different than the External mails where we use the headers...
2 Sep 2014 by HuggableAlien
Hello,I am trying to make a semi-CAD sort of program in Javascript, as I want it to be web-based, as I'm trying to make a replacement for Moraware's CounterGo for my dad.I have found many libraries and examples for making SVG and vector editors in Javascript, but my issue is saving or...
2 Sep 2014 by Kornfeld Eliyahu Peter
You can not read/write files from within a web page using JavaScript! So even you write a converter from SVG to DWG (isn't DWG a proprietary format?) you can not save it (you may send it to some server to do so, but again you may send SVG and convert it on the server)...However you can use...
9 Apr 2018 by Alfin Rusli
Dear Code Project,I have recently stumbled upon a .NET project.The core function of the project is to write data from an MSSQL database into what they called an AFP file.This AFP file is then used to initiate print out (i.e. for printing Banking Statement).From what i found out, AFP...
9 Jun 2014 by Jijo BP
All you need to do is install a AFP print driver in the system and destination file type select as pdf. From your code you need to send the binary stream to the print driver. Print driver will print it in background and the new pdf will be generated at your choice. I used it in an insurance...
10 Apr 2018 by Member 13762520
*Install AFP printer and configure it to save files with name and route. *Install Ghostcript. *use gsprint.exe to send PDF files and specify the printer to send the file and use hidden process. *I renamed the files after the printing to put the original name to the files.
27 Mar 2016 by Diether Silverious
I am working on Crystal report 2013 and I'd like to format the date in crystal reportfrom2008-04-27to April 27, 2008What I have tried:Right click on the field -> Format EditorDate and Time tabSelect date/time formatting you desirebut i can't see the date and...
3 Mar 2018 by Athari
CsConsoleFormat library for .NET - Formatting in Console using modern technologies
11 Oct 2013 by ASP.NET Community
Cascading Style SheetsAuthor: Prakash Singh MehraIntroduction: CSS is a cross platform solution for the standardization of website formatting and
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...
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[^]
28 Aug 2021 by Ali Aug2021
Currently I'm using Tidy to format my code in Vim 8.2 using ale fixers. Everything is working, but while working with Django HTML files I need to have custom line breaks which Tidy doesn't let me. My HTML code:
5 Jul 2012 by Sumit Chawla
Custom String FormatWith using Reflection
9 Jul 2012 by Matt T Heffron
This is an alternative for "Custom String FormatWith using Reflection"
4 Oct 2018 by Member 12561559
Although the cellformatting event is nicely optimised to only work on visible rows on-screen - it seems to be also the same for cells that are off-screen. Having 12-16 columns with several of these off-screen to the right of the visible cell/columns, I am setting the backgroundcolor property...
4 Oct 2018 by Alek Massey
If your DataGridView or the columns that decide cell style are read-only, you should change DefaultCellStyle of rows in RowsAdded event. This event occurs only once when a new row is added. The condition you are examining should be evaluated then and DefaultCellStyle of the row should be set...
14 Dec 2014 by Uknownymous
I have a Login/Logout system that compute the total hours work of the employees. My problem is the formatting of the date&time difference for minutes. Example:if user logged-in 8:00 AM and logged-out 6:30 PM, the total should be 10.50 but my SQL output is 10 hrs and 30 mins. I know the...
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'
21 Feb 2013 by Ali_100
if (dtProcedureDocs != null) { DataTable dt = GetProcedureDocssDatatable(); string DocTitleID = lstofWF.Where(o => o.FName == "Document Title").Select(s => s.FID).FirstOrDefault().ToString(); ...
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
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 =...
21 Dec 2013 by Wombooo
I wrote a snippet of code and i can't get it to be formatted (decimal). Here is my code: Collapse | Copy Code import java.text.DecimalFormat;import java.util.*;public class Mean { public static void main(String [] args){ Scanner s = new Scanner(System.in); ...
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...
22 Dec 2013 by Wombooo
it's alright buddy, i already figured it out... ;D
11 Apr 2013 by Hammad Raza
Hi,I accidentally formatted one of my drive, most of the files were encrypted (using windows7 EFS) and some were not, I used Recover My Files software to recover file, it recovered all files and folder.But those encrypted files are directly opening in WordPad and not human readable but...
11 Oct 2013 by ASP.NET Community
The basic difference between them is that a div is block level element and a span is inline level element. and tags both allow a Web
15 Apr 2016 by Shubham_Dubey
#includemain(){ char name[15],age[3]; printf("Please enter your name :\n"); scanf("%[^$]",&name); printf("Your name is %s.\n",name); printf("Please enter your age :\n"); scanf("%s",&age); printf("Your age is %s\n",age); getch();}Input :Shubham$$Output...
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"...
28 May 2013 by Mahmut Koyuncu
Hi, my problem is that. I tried to write number in a format. In this format, if this number is an integer only put after the digits. Input Output12.0 "12."12.2 "12.2"I tried String.Format("{0:0.###}", number)), but it is not work. It convert integer number to string...
28 May 2013 by Dave Kreskowiak
Read the documentation on String.Format and Custom Number Formats.Replace the "#" characters with "0".
28 May 2013 by CHill60
I'm not aware of any culture settings that display a decimal point after a number that does not have any decimal places (I've been through the entire CultureInfo.GetCultures that are installed here). The closest you can get is with Dave Kreskoviak's solution of String.Format("{0:0.0##}",...
3 Dec 2014 by Kinna-10626331
This is driving me crazy. I work around time format lately. I get a value from a slider as a double. Then I convert the value into Time because I need to display the value into time format : [00:00:00.00] on a textblock. My problem is that with my code now I am printing the value like this:...
3 Dec 2014 by Kornfeld Eliyahu Peter
Use TimeSpan.ToString method to format output...http://msdn.microsoft.com/en-us/library/1ecy8h51(v=vs.110).aspx[^]
4 Dec 2014 by Kinna-10626331
A solution was: var slider = sender as Slider; double sliderValue = Math.Round(slider.Value,2); TimeSpan Time = TimeSpan.FromHours(sliderValue); this.TimeText.Text = String.Format("{0:hh\\:mm\\:ss}",Convert.ToString(Time));
4 Dec 2014 by DamithSL
this.TimeText.Text = Time.ToString("hh\\:mm\\:ss\\:ff");
22 Aug 2012 by wborgsm
How to draw muliline formatted text on a System.Drawing.Graphics object.
4 Nov 2013 by Vitaliy Sytnik
On the Internet you can find a lot of different information about creating drawings in SVG format. Often an editor is used to open an DXF and export as SVG. Looking through the SVG code it is immediately obvious that there is a lot of excess. An SVG file created in one editor may not always be corre
24 Feb 2016 by akhil.krish
higridview formatting dynamically change gridview cell color based on cell value in AspNet my code:protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { this.BindGrid(); } } private void BindGrid() { ...
24 May 2012 by IBBR
Hi i have a requirement where i want to encryption the the string like "this is my test application" using a key provided "1DB5-709D-2ADC-5126-AE94-512F-D69D-3E70" and then encrypt the data as below format "8a7d-95b3-1b69-450d-e7af-2adf-3a78-4b68-0481-98f1".I have tried the normal way of...
27 Nov 2014 by GeorgeGkas
Hi guys,So I have a Toshiba Satelite L750 series laptop. I wanted to format it from usb (cause the DVD driver is down). I booted up the usb and everything worked fine until when I pressed the Install button to begin the procidery. First the machine gave me and error "Can't find...
27 Nov 2014 by GeorgeGkas
Ok i found it! Just isntall win8 from usb! You don't need to change anything!
13 Mar 2018 by Member 13424692
Hey guys, sorry to post an error message, but I am really having trouble here. I have a c# winforms project that gets this error message: ************** Exception Text ************** System.FormatException: Input string was not in a correct format. at...