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

Formating 

16 Oct 2018 by #realJSOP
Well, each column appears to be a fixed width, so simply figure out how many characters wide each column is, and for each string in the file, do a Trim(Substring(line, x, y)) where x is the index into the string to start in, and y is the width of the column. Don't forget to NOT parse anything...
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'
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);
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}??
14 Jun 2012 by Abey Kuruvila
Hi!I need help.I want to format part of a String for a DataGridViewCel in vb.net.The thing that I'm doing is, inputting details of a person in a datagridview.So the data is supposed to be formatted with different fonts and then displayed on the DGV cell.SO bascially my data consists...
7 Nov 2013 by Abhinav S
CAST and CONVERT[^] should help you convert datetime frim one format to another.Just run the query with appropriate conditions once done.
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[^].
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/[^]
10 Mar 2011 by Ahmad Negm
Hello !!I just want to format the returned date from the data reader into "yyyy/MM/dd"I have a DataReader and TextBox, i want to set one of DataReader values in the TextBox ... This value represents a date value from SQL Server DB. I did the following:txtDate.Text =...
3 Sep 2013 by Ahmed_Mostafa
This is a useful tip for formatting numbers in C#.
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() { ...
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...
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...
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:
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(); ...
22 Feb 2013 by Ali_100
I did it by the linkClick
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...
11 Nov 2013 by Andy Bantly
An understanding of the record structure for a string record in the XLSB file format.
13 Oct 2014 by Arora_Ankit
DateTime column will save time also even if you will not pass that value in insert.So, if you just want to save date then use date datatype or while fetching the record fetch record with conevrt function to get desired format else last option for you is use Varchar(10) as datatype and save in...
17 Jul 2014 by ArunRajendra
This is not a browser problem but the data. The data contains some non numeric values. You need to validate before processing.
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...
11 Oct 2013 by ASP.NET Community
IntroductionWhen and how to use sql formatting functions to format datetime values when it is being used by the application that is target to be run
11 Oct 2013 by ASP.NET Community
When I read about Jquery templating engine , I thought of giving it a try in my leisure time and I created something which can easy the lives of me
11 Oct 2013 by ASP.NET Community
ThemesAuthor: Prakash Singh MehraIntroduction: Themes are the way to define the formatting details for various controls and can be reused in
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
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
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...
3 Mar 2018 by Athari
CsConsoleFormat library for .NET - Formatting in Console using modern technologies
5 Apr 2011 by Ayman Shaltout
I want to Read the Header File from "*.*Fits" Image and save the Parameters to a database, so I Can search for them later. Using C#, LinQ.
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..
5 Apr 2013 by bEGI23
Convert filesize (bytes) according to highest possible size scale (KB, MB, GB, TB, PB).
8 Jun 2011 by Ben Kotvis
Pascal and Camel Case to display text conversion
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.
13 Nov 2022 by BernardIE5317
Greetings Kind Regards I am attempting to utilize C++ std::format and pass the format string by name. However this results in compile error as shown below. I have a very long format string and do not wish to stick it in the call site. I do not...
21 Jan 2015 by Bhis
Read XML File and change date contents
24 Jul 2014 by Bhushan Shah1988
Hello,I have different strings like string s = "11.2.1";string s1 = "53.12.1";string s2 = "9.2.11";string s3 = "1.12.1";And I want Output like s = "110201";s1 = "531201";s2 = "090211";s3 = "011201";Note: String's length is always less than 9 and there is always 2...
17 Jan 2012 by BillWoodruff
Suppose you have some sample code that uses formatted strings written to the Console: like:Console.WriteLine("{0} (quantity {1}) was replaced by {2}, (quantity {3}).", item.Description, item.Quantity, replacement.Description, replacement.Quantity);And, you'd like to quickly convert all...
28 Feb 2011 by brainflex
Hello Code Warriors,I have 2 problems with a program I am writing for my first year CS course. It must be written in ANSI 'C':Here is a sketch of my algorithm:/*********************************************/ int main() { initialize(); calculateData(); ...
12 Nov 2013 by brknlpr
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using System.IO;using System.Text.RegularExpressions;namespace...
18 Nov 2013 by CAS1224
Hello. I have a vb.net windows forms application that is using a datagridview. I'm hoping to find a simple way to format certain datagridview cells numbers to 3 decimal places. This is what I have so far, but it doesn't seem to format everything correctly. ...
27 Feb 2017 by CAS1224
I'm hoping to find a simple way to convert an entire column in my datagridview from a string data type to a decimal. Something simple like this maybe? DataGridView1.Columns(4).ValueType = Decimal
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[^]
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 ",...
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.
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##}",...
2 Apr 2016 by CHill60
KittoKy wrote:but all are talking about exceptions and errors which are not solving my issueYour code is throwing an exception (error) and that text is the message associated with it. It is appearing as "output" from your program because it is a Console program.You have been told how to find...
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...
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...
22 Dec 2013 by codeninja-C#
Hi,i would like to know the total supported HTML tags by infragistics Gidview.Can you provide all the supported HTML tags?Thanks--SJ
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[^]
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!"); ...
4 Dec 2014 by DamithSL
this.TimeText.Text = Time.ToString("hh\\:mm\\:ss\\:ff");
17 Jun 2015 by Daria90
I have this text input that has to convent the value in the German price format on .blur(). It works when the user presses period for the decimal separator, but since I have a German keyboard I would like to press the comma to get the same results. I added a code snippet below for a...
17 Jun 2015 by Daria90
Here you guys, I made this JsFiddle : http://jsfiddle.net/Daria90/zuxu5tva/2/[^]
14 Jun 2012 by Dave Kreskowiak
How? You don't!It works exactly the same as a normal TextBox control. You can only have a single font in a cell.You cannot use multiple fonts, sizes and formatting styles in the same cell using the default TextBox column. In order to implement this, you'd have to design your own...
28 May 2013 by Dave Kreskowiak
Read the documentation on String.Format and Custom Number Formats.Replace the "#" characters with "0".
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.
13 Mar 2018 by Dave Kreskowiak
Basically, it means that whatever text you're trying to convert to a number type, or date type, is not a string of characters that can be converted to that type. If you enter "AXG012" and then type to convert that to an integer, you'll get the error you're talking about. In your example, it...
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.
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...
9 May 2013 by David_Wimbley
You were pretty much there. The following code takes this input1. The element 50m 45sdefines a title in the browser toolbar 15m 20sprovides a title for the page when it is added to favorites 15m 10sdisplays a title for the page in search-engine results 20m 15s2. CSS can be...
26 Sep 2016 by David_Wimbley
Google is your friend. I simply googled format numbers with spaces in c# and it returned 1.16 million results.It appears the route that is suggested is to make your own custom number formatter. Although sometimes the easiest way out isn't half bad (.Replace(",", " "))Google[^]decimal...
18 Jan 2019 by DavidMorf
Hi all, I've made a custom datagridview with Excel export functionality and stumbled upon a problem I can't seem to fix. I'm trying to format the excel columns according to their datatype and giving an array to the Microsoft.Office.Interop.Excel object. When my grid column is of any of the...
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) ...
13 Nov 2013 by Debopam Pal
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...
19 Apr 2013 by DImitrijex
Is there any tool I can use to format SQL Server code? I’d like to find a quick and dirty solution where I can just open script, click format and then save it.
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 =...
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.....
3 Jan 2015 by Doug Vanderweide
I'm not sure why you even need a form to do this. It's a very simple pattern: First letter of the first group, entire number in the third group, fourth group.That said, it's very simple regular expression:^([A-Z]{1})[A-Z]{2} \d{2} (\d{6}) ([A-Z]{1}) [A-Z]{3}$In theory you can do...
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...
7 May 2013 by duonglg
Please help me:I have paragraph, copy to textbox:----------------------------------------------------------------1. The element 50m 45sdefines a title in the browser toolbar 15m 20sprovides a title for the page when it is added to favorites 15m 10sdisplays a title for the...
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!
13 Jun 2021 by Eric Dubois
Hi, I would like to add a radio button in a column of a webgrid in Asp VB .Net But, I can't understand the syntax. What I have tried: I tried : grdProfils.Column("Select",, Function(ret) @html.RadioButton("ProfilId", item.Id, False)), But :...
13 Jun 2021 by Eric Dubois
And the solution is : grdProfils.Column("Select", Nothing, format:= Function(item) Return Html.RadioButton("ProfilId", item.Id, False) End Function),
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
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
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
28 Mar 2016 by F-ES Sitecore
They basically mean can you take text and make it look right\nice on a web page. If you look at a news article likeOculus founder delivers first Rift headset in person - BBC News[^]Underlying the page is html that puts things in paragraphs, has titles, links, bold text etc. They're...
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...
7 Feb 2011 by Fatih P.
Here is the one i wrote sometime ago/* ---------------------------------------------------------------------------- * Teknober.com - All rights reserved * ---------------------------------------------------------------------------- * File Name : TStringBuilder.php * Section ...
27 Oct 2014 by Filipe Morgan
I am looking for a simple solution for converting a PDF file into any image format. I am trying to avoid using paid libraries.The goal is to, after converion, show a preview of the first PDF page inside a panel. To accomplish that, I need to convert at least the first page of the file into...
22 Mar 2017 by Fiyaz Hasan
Know how to create a custom request/response formatter for ASP.NET Core apps
26 Sep 2016 by Foothill
If you are being feed the number as a string with the thousands separator already in there, this is a functional but dirty solution.char[] numberText = value.ToCharArray();for (int i = 0; i
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 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 =...
18 Nov 2013 by Ganesh KP
Hi CAS1224, have you tried this Me.DataGridView1.Columns(2).DefaultCellStyle.Format = "n3"try this, hope this worksThanksGanesh
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[^].
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!
4 Sep 2014 by Gihan Liyanage
Use padding .gridview{ padding-left: 10px; padding-right: 10px;}
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.
29 Mar 2013 by Gopinath_Rajan
LblExpirydate.Text = dataReader(0).ToString("dd-MM-yyyy")
17 Jan 2017 by GrabiCraft
So I have quite a newbie question:What if I want to say like:if (dog != "cat" or "cow"){ Console.WriteLine("A dog is not equal to a cow nor a cat!");}And 'II' cannot be used since I am using strings.What I have tried:I tried the II but since I have a string it wouldn't work
23 Mar 2017 by Graeme_Grant
You don't need to format the string in code. You can do it in Xaml. Also, OnPropertyChange handling needs cleaning up. Below code will address both.INotifyPropertyChanged wrapperusing System.ComponentModel;using System.Runtime.CompilerServices;namespace WpfBindingEvents{ public...
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 ...
23 Oct 2013 by Gregory Gadow
The small date is based on the system date format: it cannot be formatted by code. Try this:Open the control panel, find the regional settings ("Region and Language" in Win 7.)Change the short date format to something unusual, such as the ANSI format (yyyy-MM-dd). Save changes.Run your...
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...