Working with calendar in PowerShellStudio
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Working with calendar in PowerShellStudio
Can I ask another question? I also need this date to do a search in the databases.I can use the variable $this SQL query? Or maybe assign it a different type?
Re: Working with calendar in PowerShellStudio
Windows is based on an event driven model or what we can call a state machine.. Windows always send at least one object with an event. That object is internally assigned t the $this variable and is formally known as the "sender". The variable life expectancy is the lifetime of the event. There is an optional second parameter which is known as the event parameter and it is assigned to the $_ internal variable when needed. PowerShell Studio always (I think) posts the class of the event object so we know what it can do. Here is an example:nikolay wrote:Thank you for your help!!! But it difficult for me.And it is not work.
What is this variable $this?
This variable needs to be stored a date which choosed on calendar?
- #Event Argument: $_ = [System.ComponentModel.CancelEventArgs]
Here is what it looks like from the SDK point of reference.
Here is a control click event:
private void button1_Click(object sender, System.EventArgs e)
Here is the value changed event handler:
private void DateTimePicker1_ValueChanged(Object sender, EventArgs e)
Notice that they are generically the same. The e in the DTP event is just not very useful so we ususally ignore it.
Most controls have a "Spotlight article" available via a right click on the control in the toolbox. Unfortunately no one has written an article for the DTP so we cannot review it. We can look it up in the SDK at Microsoft.
For any control use this template: https://msdn.microsoft.com/en-us/librar ... dows.forms
We then add the control class name and we can find the documentation:
https://msdn.microsoft.com/en-us/librar ... timepicker
It is critical that you learn to use the documentation when learning PowerShell and Forms. It will help you to ask better questions when posting for help.
Re: Working with calendar in PowerShellStudio
Before going any further you need to learn PowerShell. Until then you will be totally lost and we cannot incrementally teach you how to use PowerShell.nikolay wrote:Can I ask another question? I also need this date to do a search in the databases.I can use the variable $this SQL query? Or maybe assign it a different type?
Re: Working with calendar in PowerShellStudio
Here is a research starter for how to use SQL with PowerShell:
https://www.google.com/?gws_rd=ssl#neww ... ql+example
https://www.google.com/?gws_rd=ssl#neww ... ql+example
- dan.potter
- Posts: 709
- Last visit: Wed Nov 14, 2018 11:39 am
Re: Working with calendar in PowerShellStudio
As long as the sql query is within the event block. Otherwise you'll have to declare another variable which may require scoping( I always use the datetimepicker in it's own child form). As JVierra pointed out $this is only available within the event.nikolay wrote:Can I ask another question? I also need this date to do a search in the databases.I can use the variable $this SQL query? Or maybe assign it a different type?
Depending on the size of your table you might choose to write your sql select statement to return rows of $this greater than datetime column or return all rows then let powershell do that work with | ? {$_.datetimecolumn -gt $this}.