Click here to Skip to main content
15,885,197 members
Home / Discussions / C#
   

C#

 
Questionhow to print POS bills with a thermal printer Pin
Meax24-Jan-21 8:53
Meax24-Jan-21 8:53 
AnswerRe: how to print POS bills with a thermal printer Pin
Daniel Pfeffer24-Jan-21 9:23
professionalDaniel Pfeffer24-Jan-21 9:23 
GeneralRe: how to print POS bills with a thermal printer Pin
OriginalGriff24-Jan-21 10:25
mveOriginalGriff24-Jan-21 10:25 
AnswerRe: how to print POS bills with a thermal printer Pin
OriginalGriff24-Jan-21 10:26
mveOriginalGriff24-Jan-21 10:26 
QuestionRuntime error in PivotGridControl data binding [Solved] Pin
Alex Dunlop21-Jan-21 8:48
Alex Dunlop21-Jan-21 8:48 
AnswerRe: Runtime error in PivotGridControl data binding Pin
Gerry Schmitz21-Jan-21 9:02
mveGerry Schmitz21-Jan-21 9:02 
AnswerRe: Runtime error in PivotGridControl data binding Pin
Richard Deeming21-Jan-21 22:05
mveRichard Deeming21-Jan-21 22:05 
AnswerRe: Runtime error in PivotGridControl data binding Pin
OriginalGriff21-Jan-21 22:22
mveOriginalGriff21-Jan-21 22:22 
Just to add to what Richard has said...

When you create a form, all the "heavy lifting" of creating controls, setting form properties, and suchlike is performed for you in the MyFile.Designer.cs file method InitializeComponent, which is why the default Form file always contains a constructor which calls it as the first line of code.
This file is created and maintained by the VS designer and isn't normally edited directly.

If you don't call InitializeComponent when you edit the Form constructor, then no controls or properties are ever created for you, and the variables allocated by the designed for them will remain empty - they will contain the default value for a reference value: null

So when your code tries to use them for anything at all, you will get a null reference error, as you have seen.

To be honest, you should have spotted that yourself, and thirty seconds with the debugger would have put you on the right track pretty much immediately! It's worth getting used to the debugger, it's your best friend and will save you hours of hair pulling frustration!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!

GeneralRe: Runtime error in PivotGridControl data binding Pin
Alex Dunlop21-Jan-21 22:44
Alex Dunlop21-Jan-21 22:44 
GeneralRe: Runtime error in PivotGridControl data binding Pin
Alex Dunlop21-Jan-21 23:07
Alex Dunlop21-Jan-21 23:07 
GeneralRe: Runtime error in PivotGridControl data binding Pin
OriginalGriff21-Jan-21 23:30
mveOriginalGriff21-Jan-21 23:30 
Question[Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
chipp_zanuff21-Jan-21 0:34
chipp_zanuff21-Jan-21 0:34 
AnswerRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
OriginalGriff21-Jan-21 0:59
mveOriginalGriff21-Jan-21 0:59 
GeneralRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
chipp_zanuff21-Jan-21 5:56
chipp_zanuff21-Jan-21 5:56 
AnswerRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
Richard MacCutchan21-Jan-21 1:37
mveRichard MacCutchan21-Jan-21 1:37 
GeneralRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
chipp_zanuff21-Jan-21 5:40
chipp_zanuff21-Jan-21 5:40 
GeneralRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
Richard MacCutchan21-Jan-21 5:53
mveRichard MacCutchan21-Jan-21 5:53 
GeneralRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
chipp_zanuff21-Jan-21 6:03
chipp_zanuff21-Jan-21 6:03 
GeneralRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
Richard MacCutchan21-Jan-21 6:36
mveRichard MacCutchan21-Jan-21 6:36 
GeneralRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
chipp_zanuff22-Jan-21 4:41
chipp_zanuff22-Jan-21 4:41 
GeneralRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
Richard MacCutchan22-Jan-21 5:42
mveRichard MacCutchan22-Jan-21 5:42 
AnswerRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
Gerry Schmitz21-Jan-21 3:44
mveGerry Schmitz21-Jan-21 3:44 
GeneralRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
chipp_zanuff21-Jan-21 5:50
chipp_zanuff21-Jan-21 5:50 
GeneralRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
Gerry Schmitz21-Jan-21 8:48
mveGerry Schmitz21-Jan-21 8:48 
GeneralRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
chipp_zanuff22-Jan-21 4:43
chipp_zanuff22-Jan-21 4:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.