Click here to Skip to main content
14,768,479 members
Home » Discussions » C#
   

C#

 
Questionhow to print POS bills with a thermal printer Pin
Meax24-Jan-21 9:53
MemberMeax24-Jan-21 9:53 
AnswerRe: how to print POS bills with a thermal printer Pin
Daniel Pfeffer24-Jan-21 10:23
professionalDaniel Pfeffer24-Jan-21 10:23 
GeneralRe: how to print POS bills with a thermal printer Pin
OriginalGriff24-Jan-21 11:25
mveOriginalGriff24-Jan-21 11:25 
AnswerRe: how to print POS bills with a thermal printer Pin
OriginalGriff24-Jan-21 11:26
mveOriginalGriff24-Jan-21 11:26 
QuestionRuntime error in PivotGridControl data binding [Solved] Pin
Alex Dunlop21-Jan-21 9:48
MemberAlex Dunlop21-Jan-21 9:48 
AnswerRe: Runtime error in PivotGridControl data binding Pin
Gerry Schmitz21-Jan-21 10:02
mveGerry Schmitz21-Jan-21 10:02 
AnswerRe: Runtime error in PivotGridControl data binding Pin
Richard Deeming21-Jan-21 23:05
mveRichard Deeming21-Jan-21 23:05 
AnswerRe: Runtime error in PivotGridControl data binding Pin
OriginalGriff21-Jan-21 23:22
mveOriginalGriff21-Jan-21 23: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 23:44
MemberAlex Dunlop21-Jan-21 23:44 
GeneralRe: Runtime error in PivotGridControl data binding Pin
Alex Dunlop22-Jan-21 0:07
MemberAlex Dunlop22-Jan-21 0:07 
GeneralRe: Runtime error in PivotGridControl data binding Pin
OriginalGriff22-Jan-21 0:30
mveOriginalGriff22-Jan-21 0:30 
Question[Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
chipp_zanuff21-Jan-21 1:34
Memberchipp_zanuff21-Jan-21 1:34 
AnswerRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
OriginalGriff21-Jan-21 1:59
mveOriginalGriff21-Jan-21 1:59 
GeneralRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
chipp_zanuff21-Jan-21 6:56
Memberchipp_zanuff21-Jan-21 6:56 
AnswerRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
Richard MacCutchan21-Jan-21 2:37
mveRichard MacCutchan21-Jan-21 2:37 
GeneralRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
chipp_zanuff21-Jan-21 6:40
Memberchipp_zanuff21-Jan-21 6:40 
GeneralRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
Richard MacCutchan21-Jan-21 6:53
mveRichard MacCutchan21-Jan-21 6:53 
GeneralRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
chipp_zanuff21-Jan-21 7:03
Memberchipp_zanuff21-Jan-21 7:03 
GeneralRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
Richard MacCutchan21-Jan-21 7:36
mveRichard MacCutchan21-Jan-21 7:36 
GeneralRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
chipp_zanuff22-Jan-21 5:41
Memberchipp_zanuff22-Jan-21 5:41 
GeneralRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
Richard MacCutchan22-Jan-21 6:42
mveRichard MacCutchan22-Jan-21 6:42 
AnswerRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
Gerry Schmitz21-Jan-21 4:44
mveGerry Schmitz21-Jan-21 4:44 
GeneralRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
chipp_zanuff21-Jan-21 6:50
Memberchipp_zanuff21-Jan-21 6:50 
GeneralRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
Gerry Schmitz21-Jan-21 9:48
mveGerry Schmitz21-Jan-21 9:48 
GeneralRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
chipp_zanuff22-Jan-21 5:43
Memberchipp_zanuff22-Jan-21 5: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.