my checkboxes are null references
my checkboxes are null references
13 Dec 2023, 09:35
hey there,
At one point in my code I have this:
var chkboxSells = new CheckBox
{
Text = "Sells",
HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Center,
IsChecked = false
};
and later on i have this..
var includeSells = chkboxSells.IsChecked;
but i've also tried this and a zillion variations..
var includeSells = chkboxSells != null && (bool)chkboxSells.IsChecked;
in the first attempt i get crashes due to null object references, and in the 2nd I can never get a checkd result to come through as true
Can anyone help me understand how to handle this?
Replies
ctid4921325
13 Dec 2023, 10:39
( Updated at: 14 Dec 2023, 06:43 )
RE: my checkboxes are null references
PanagiotisCharalampous said:
Hi there,
It's hard to tell what the problem is with just some samples of the code. You should share the complete cBot code so that we can reproduce the problem.
Best regards,
Panagiotis
THanks Panagiotis, really appreciate that.. it was to big to paste here, but here's a link. I think its line 368 that hits the error. pls excuse the coding, its my first c# effort
https://gist.github.com/glenndavy/1e15326378b01bd43deb9fe171d55564
@ctid4921325
ctid4921325
13 Dec 2023, 10:41
( Updated at: 14 Dec 2023, 06:43 )
RE: my checkboxes are null references
PanagiotisCharalampous said:
Hi there,
It's hard to tell what the problem is with just some samples of the code. You should share the complete cBot code so that we can reproduce the problem.
Best regards,
Panagiotis
also, to replicate.. you need to place some trades, then choose your checkbox options then “Move Stoploss”
Thanks
@ctid4921325
PanagiotisCharalampous
14 Dec 2023, 07:02
RE: RE: my checkboxes are null references
ctid4921325 said:
PanagiotisCharalampous said:
Hi there,
It's hard to tell what the problem is with just some samples of the code. You should share the complete cBot code so that we can reproduce the problem.
Best regards,
Panagiotis
also, to replicate.. you need to place some trades, then choose your checkbox options then “Move Stoploss”
Thanks
Hi there,
I tried for a while to reproduce it but with no luck. Can you provide more specific steps we need to follow to reproduce this?
Best regards,
Panagiotis
@PanagiotisCharalampous
... Deleted by UFO ...
ctid4921325
14 Dec 2023, 07:45
( Updated at: 21 Dec 2023, 09:23 )
RE: RE: RE: my checkboxes are null references
PanagiotisCharalampous said:
ctid4921325 said:
PanagiotisCharalampous said:
Hi there,
It's hard to tell what the problem is with just some samples of the code. You should share the complete cBot code so that we can reproduce the problem.
Best regards,
Panagiotis
also, to replicate.. you need to place some trades, then choose your checkbox options then “Move Stoploss”
Thanks
Hi there,
I tried for a while to reproduce it but with no luck. Can you provide more specific steps we need to follow to reproduce this?
Best regards,
Panagiotis
Hey Panagoitis, thanks for going to this effort. Simplest reproduction is
Step 1)
Place a trade
Step 2) Click the “Close selected trades” button, Feel free to toggle any of the checkboxes, results are the same.
Step 3) See "Crashed in Click event with NullReferenceException: Object reference not set to an instance of an object.
Thanks!
@ctid4921325
PanagiotisCharalampous
14 Dec 2023, 09:16
( Updated at: 21 Dec 2023, 09:23 )
RE: RE: RE: RE: my checkboxes are null references
ctid4921325 said:
PanagiotisCharalampous said:
ctid4921325 said:
PanagiotisCharalampous said:
Hi there,
It's hard to tell what the problem is with just some samples of the code. You should share the complete cBot code so that we can reproduce the problem.
Best regards,
Panagiotis
also, to replicate.. you need to place some trades, then choose your checkbox options then “Move Stoploss”
Thanks
Hi there,
I tried for a while to reproduce it but with no luck. Can you provide more specific steps we need to follow to reproduce this?
Best regards,
Panagiotis
Hey Panagoitis, thanks for going to this effort. Simplest reproduction is
Step 1)
Place a trade
Step 2) Click the “Close selected trades” button, Feel free to toggle any of the checkboxes, results are the same.
Step 3) See "Crashed in Click event with NullReferenceException: Object reference not set to an instance of an object.
Thanks!
Hi there,
Unfortunately the code you have shared has less parameters and displays nothing on the chart. So we are probably not running the same code
Best regards,
Panagiotis
@PanagiotisCharalampous
ctid4921325
14 Dec 2023, 16:37
( Updated at: 21 Dec 2023, 09:23 )
RE: RE: RE: RE: RE: my checkboxes are null references
PanagiotisCharalampous said:
ctid4921325 said:
PanagiotisCharalampous said:
ctid4921325 said:
PanagiotisCharalampous said:
Hi there,
It's hard to tell what the problem is with just some samples of the code. You should share the complete cBot code so that we can reproduce the problem.
Best regards,
Panagiotis
also, to replicate.. you need to place some trades, then choose your checkbox options then “Move Stoploss”
Thanks
Hi there,
I tried for a while to reproduce it but with no luck. Can you provide more specific steps we need to follow to reproduce this?
Best regards,
Panagiotis
Hey Panagoitis, thanks for going to this effort. Simplest reproduction is
Step 1)
Place a trade
Step 2) Click the “Close selected trades” button, Feel free to toggle any of the checkboxes, results are the same.
Step 3) See "Crashed in Click event with NullReferenceException: Object reference not set to an instance of an object.
Thanks!
Hi there,
Unfortunately the code you have shared has less parameters and displays nothing on the chart. So we are probably not running the same code
Best regards,
Panagiotis
not sure i follow, what i've got here is the same with some unrelated changes.. but i'll repost the full current version, there's the updated version used to create the error with “Close selected trades” button on the above images:
> https://gist.github.com/glenndavy/1e15326378b01bd43deb9fe171d55564
@ctid4921325
ctid4921325
14 Dec 2023, 16:37
( Updated at: 21 Dec 2023, 09:23 )
RE: RE: RE: RE: RE: my checkboxes are null references
PanagiotisCharalampous said:
ctid4921325 said:
PanagiotisCharalampous said:
ctid4921325 said:
PanagiotisCharalampous said:
Hi there,
It's hard to tell what the problem is with just some samples of the code. You should share the complete cBot code so that we can reproduce the problem.
Best regards,
Panagiotis
also, to replicate.. you need to place some trades, then choose your checkbox options then “Move Stoploss”
Thanks
Hi there,
I tried for a while to reproduce it but with no luck. Can you provide more specific steps we need to follow to reproduce this?
Best regards,
Panagiotis
Hey Panagoitis, thanks for going to this effort. Simplest reproduction is
Step 1)
Place a trade
Step 2) Click the “Close selected trades” button, Feel free to toggle any of the checkboxes, results are the same.
Step 3) See "Crashed in Click event with NullReferenceException: Object reference not set to an instance of an object.
Thanks!
Hi there,
Unfortunately the code you have shared has less parameters and displays nothing on the chart. So we are probably not running the same code
Best regards,
Panagiotis
not sure i follow, what i've got here is the same with some unrelated changes.. but i'll repost the full current version, there's the updated version used to create the error with “Close selected trades” button on the above images:
> https://gist.github.com/glenndavy/1e15326378b01bd43deb9fe171d55564
@ctid4921325
PanagiotisCharalampous
15 Dec 2023, 06:18
Hi there,
Your problem is here
var chkboxSells = new CheckBox
{
Text = "Sells",
HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Center,
IsChecked = false
};
var chkboxBuys = new CheckBox
{
Text = "Buys",
HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Center,
IsChecked = false
};
Remove the var keyword and the issue should be fixed.
Best regards,
Panagiotis
@PanagiotisCharalampous
ctid4921325
15 Dec 2023, 06:21
RE: my checkboxes are null references
PanagiotisCharalampous said:
Hi there,
Your problem is here
var chkboxSells = new CheckBox { Text = "Sells", HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Center, IsChecked = false };
var chkboxBuys = new CheckBox { Text = "Buys", HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Center, IsChecked = false };
Remove the var keyword and the issue should be fixed.
Best regards,
Panagiotis
oh embarrassing.. but , thanks so much… sorry brand new to c#… thanks again, your support is incredible.
@ctid4921325
ctid4921325
15 Dec 2023, 06:21
RE: my checkboxes are null references
PanagiotisCharalampous said:
Hi there,
Your problem is here
var chkboxSells = new CheckBox { Text = "Sells", HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Center, IsChecked = false };
var chkboxBuys = new CheckBox { Text = "Buys", HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Center, IsChecked = false };
Remove the var keyword and the issue should be fixed.
Best regards,
Panagiotis
oh embarrassing.. but , thanks so much… sorry brand new to c#… thanks again, your support is incredible.
@ctid4921325
PanagiotisCharalampous
13 Dec 2023, 10:22
Hi there,
It's hard to tell what the problem is with just some samples of the code. You should share the complete cBot code so that we can reproduce the problem.
Best regards,
Panagiotis
@PanagiotisCharalampous