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

13 Mar 2023 by Member 12617947
I have a string whose part is always changing, and I want to remove that part from the string like this: Our society, 01:12:15:14 the whole country Our society, the whole country This format should be removed from the string: 01:12:15:14 This...
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: ' ...
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 ...
10 Mar 2023 by Mark Pelf
Beginner’s tutorial on PE format, with illustrations
13 Nov 2022 by Richard MacCutchan
The format string must be a constant expression, see std::format - cppreference.com[^]. [edit] I have been looking at the documentation (per the above link), and trying some tests. Even using the string: const char* fmt = "{}"; produces the...
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...
5 Sep 2022 by Member 11641721
Hi my date value is Wed Sep 07 2022 00:00:00 GMT+0430 (Iran Daylight Time) when convert it to json by console.log(mydate.toJSON()); console.log(JSON.stringify(mydate.toDate())); Output is 2022-09-06T19:30:00.000Z I need this...
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);
2 May 2022 by Mat 257
hello everybody. i m facing what i suppose being an excel bug. below issue code Dim QuestoBook As Workbook Set QuestoBook = ActiveWorkbook Application.EnableEvents = False QuestoBook.Sheets(1).Range("E6").Value = SourceSheet.Range("E2").Value...
2 May 2022 by Mat 257
I found a way around, instead of trasfer the value only from source to destination, i transfer the fromatting as well with this Questbook.range(e6).Numberformat=source.range(e6).numberformat. It works Thanks
24 Apr 2022 by Saba Minashvili
So there is the method that executes an API Call public async Task ExecuteAsync(ClientTotalRequest totalRequest) { // Defining path using provided "options" value var path =...
24 Apr 2022 by Saba Minashvili
The problem was next: Instead of using this code in ExecuteAsync method _logger.LogInformation($"Request is {JsonSerializer.Serialize(totalRequest)}.", LogLevel.Information); _logger.LogInformation($"Response is...
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...
26 Jan 2022 by MMT - ElectriX
So basically, a user is gonna type in the hours in an inputfield and I'm gonna get the amount they write as an int in my code. public InputField hours, minutes; public int wantedHours, wantedMinutes; Basically what I want is that people are...
26 Jan 2022 by MMT - ElectriX
THIS WORKED FOR ME: string wantedHoursString = hours.text; if (int.TryParse(hours.text, out int result)) { wantedHours = result; } string wantedMinuteString = minutes.text; if...
23 Oct 2021 by honey the codewitch
A handy code snippet that can set indentation levels while rendering multipart documents with a TextWriter
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:
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 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),
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:
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 =...
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 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 ",...
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"...
23 Feb 2019 by Member 14160395
Hi Guys! got myself in a tight spot here, the widget on the right hand side of my website has lost its formatting, i need it all in one line, and to drop below the left hand widget when viewed in mobile: https://aurexgroup.com/ Im using a enfold child theme on a wordpress site. i assume its a...
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...
18 Jan 2019 by Maciej Los
Check this: Range.NumberFormat property (Excel) | Microsoft Docs[^] and this: MS Excel: How to use the FORMAT Function with Numbers (VBA)[^] For decimals with 2 places after dot: columnRange.NumberFormat = "#,##0.00" 'keeps format: ' .803 => 0.80 ' 1.224 => 1.22 '55.556 => 55.56 For...
19 Nov 2018 by Richard MacCutchan
You can use the String.Split Method (System) | Microsoft Docs[^] to separate the three parts. You may need an initial check to see which control characters are being used.
19 Nov 2018 by Member 13621621
So I'm still getting use to VB.NET as I haven't had much time to play with it, and haven't done alot of coding since back in the vb6 days. Anyways, I'm working on a small personal project for me and my business partner to handle certain customer information. Basically it just has a few text...
16 Oct 2018 by tishi208
I am having output in the following manner. I am trying to parse that output and assign it to a datatable but i am facing difficulty because the output column text have spaces between the character because of that i am unable to split data in equal columns sample o/p List of Sessions Cell...
16 Oct 2018 by MadMyche
You need to realize that it looks like you don't need to parse a string. If you open the file up in Excel you will notice Excel recognizes this as a "Fixed-Width" file; so what you need is a file parser. There are quite a few examples of this out there. While this one is one over a decade old...
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...
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...
6 Sep 2018 by Richard MacCutchan
This is the same problem as you posted yesterday at https://www.codeproject.com/Questions/1259212/Make-values-in-an-index-replaced-by-other-values[^], where you already have an answer.
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.
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...
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...
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...
3 Mar 2018 by Athari
CsConsoleFormat library for .NET - Formatting in Console using modern technologies
17 Feb 2018 by Sami Jildeh
In WinForms, How to change text direction in RichTextBox without losing the text format? I know that there is RightToLeft option but if i used it while i have formatted text in the richtextbox all the format will be lost which it isn't a good thing in text editors. I also know that pressing...
5 Feb 2018 by NewbieAR
NVD - Data Feeds[^] I am reading the json nvd feed in the above link and trying to output the ID and the impactScore. I did all these but I don't know how to format the output file, like add each in columns with headers and new rows. Please help me or guide me to a link that will teach me this....
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) ...
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...
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 = "-"; ...
28 Apr 2017 by Patrick Skelton
Hi,I am struggling to work out how to pad an integer field with leading zeroes in the new C# interpolated strings.According to this article C#6: String Interpolation, "The same composite formatting power is there to specify things like significant figures and leading zeroes."In this...
28 Apr 2017 by Kristian Lindberg Vinther
A concrete example: var number = 123; Console.WriteLine($"{number:000000}"); // 000123
10 Apr 2017 by Member 13119650
Currently I am working on some java and ran across this problem of trying to format my code correctly onto one line. I have set the first group of numbers assigned to the variable stored as a String `string1` the second group of numbers to `string2`and my last group of numbers to `string3`....
10 Apr 2017 by Richard MacCutchan
See Formatter (Java Platform SE 7 )[^].
23 Mar 2017 by Sabyasachi Mukherjee
I have a simple view containing a Textbox and a Label. And in my ViewModel, I have private decimal myInt;public decimal MyInt{ get {...
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...
22 Mar 2017 by Fiyaz Hasan
Know how to create a custom request/response formatter for ASP.NET Core apps
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
27 Feb 2017 by Member 12863425
try to write convert it in sql .it will be easy
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
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"); ...
17 Jan 2017 by OriginalGriff
You would have to say:if (dog != "cat" && dog != "cow")Orif (!(dog == "cat" || dog == "cow"))
5 Oct 2016 by Patrice T
Are you sure this is your code and that you can't make it reply in number of days ?the change is really easy, you should be able to do it yourself.Bug report:You should check the number of seconds per years and per months, there is a surprise :)Quote:'6 months, 2 weeks, 1 hour, 44...
4 Oct 2016 by Member 12776322
My Python script is nearly there, so here it is:def prettyList(human_time): if len(human_time) > 1: return ' '.join([', '.join(human_time[:-1]), "and", human_time[-1]]) elif len(human_time) == 1: return human_time[0] else: return ""def...
28 Sep 2016 by IamWsk
Try this.txt.Text=String.Format("{0:C}", test*(-1)).Replace(",", " ");It will add currency sign also then replace the currency sign as below if you don't wanttxt.Text=String.Format("{0:C}", test*(-1)).Replace(",", " ").Replace("$", "");
28 Sep 2016 by TatsuSheva
I'm trying not to use the ',' char as a thousand separator when displaying a string, but to use a space instead. I guess I need to define a custom culture, but I don't seem to get it right. Any pointers?eg: display 1000000 as 1 000 000 instead of 1,000,000(String.Replace() is not the...
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
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...
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...
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 Jun 2016 by MarshalS
i want to create a user privileged exe that detect the formatting of USB device and inform that the device is starts formatting and when it completed it shows a message formatting is completed.What I have tried:created a c++ console application with the below example code.but it need...
8 Jun 2016 by MarshalS
I got the solution#include "stdafx.h"#include #include #include #include using namespace std;int _tmain(int argc, _TCHAR* argv[]){ while(true) { WIN32_FIND_DATA data; HANDLE h = FindFirstFile(L"D:\\*.*",&data); \\ Specify the...
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"...
15 Apr 2016 by Industria Virtual
Joinning a a Text Box and a Select Combo in a HTML Form.
2 Apr 2016 by KittoKy
I haven't used any Console.WriteLine to display the text i.e.: "Input string was not in a correct format" :( . I am trying to get data from database and save it in a double 2D array. One row in each array entry. This is my code : using System;using System.Collections.Generic;using...
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...
30 Mar 2016 by Sergey Alexandrovich Kryukov
"D" or "d" in specifier found in "Standard Numeric Format Strings" is not it. It is not leading/padding, this is "Precision specifier: Minimum number of digits". Can you see the difference? Here is an additional explanation: Standard Numeric Format Strings[^].For leading digits or padding,...
30 Mar 2016 by RickZeeland
Not exactly C# 6, but simple:string x = "3";Console.WriteLine(x.PadLeft(2, '0'))
28 Mar 2016 by Member 12421574
I've been running into a lot of writing job descriptions requiring an ability to "format" articles "in HTML." I know a little about the concept of coding, and I understand the idea of HTML as a coding language, but I'm not sure what they mean by using it to "format" a piece of writing....
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...
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...
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() { ...
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.
10 Feb 2016 by Kouji Matsui
This library is simple and is a substitution of System.String.Format.
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[^].
15 Dec 2015 by Richard MacCutchan
See https://msdn.microsoft.com/en-us/library/ms709353(v=vs.85).aspx[^].
15 Dec 2015 by leoiser
I want to extract the CSV file from SQL server and I manage to do that with the following codes. DECLARE @bcpCommand1 VARCHAR(2000) SET @bcpCommand1 = 'bcp " SELECT * from ##tblUser " queryout' SET @bcpCommand1 = @bcpCommand1 + ' C:\OutPut\CSV\My_Output.csv -c -w -T -S197.1.1.1 -Umyuser...
29 Jun 2015 by jindrich.babica
Binding with respect to CurrentCulture
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...
17 Jun 2015 by Daria90
Here you guys, I made this JsFiddle : http://jsfiddle.net/Daria90/zuxu5tva/2/[^]
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...
20 May 2015 by Richard MacCutchan
See http://www.dreamincode.net/forums/topic/144733-formatting-textbox/[^].
20 May 2015 by Member 11641897
Hello,I would lik to make my money_txtbox in format money with dt at the endexample : if user enter 1500 it must be showed as 1.500dt, any idea how can I do that ?Thanks for help
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...
5 May 2015 by Jamil Isayyed
Hello Folks,i have been trying to create a transport agent which change the Body format for internal mails which use the TNEF parts - Internal emails.what i found that the body format changed from HTML to none when i created a TNEFwriter object as follow: MimePart tnefPart...
3 Mar 2015 by Kenneth Haugland
Id think I would use String Fomat to show values:
3 Mar 2015 by hemanth kr
I am new to WPF. I have a requirement that I need to develop a custom textbox control which should support the functionality like:Should accept only decimal values.Should round off to 3 decimal places when assigned a value through code or by the user.Should show the full...
3 Mar 2015 by hemanth kr
Hey, Sorry for the late reply. I tried creating a custom control. It does contain some drawbacks but working on it.class TextBoxEx:TextBox{ public string ActualText { get { return (string)GetValue(ActualTextProperty); } set { SetValue(ActualTextProperty, value);...
20 Feb 2015 by Sergey Alexandrovich Kryukov
You can handle this event: https://msdn.microsoft.com/en-us/library/system.windows.uielement.previewtextinput%28v=vs.110%29.aspx[^].The event is cancellable so you can cancel input if the user is trying to input something wrong. Please see this review:...