-->

Catch cursor keys on the KeyDown event

maqk® by Unknown | 3:53 AM

Making KeyDown event work for Cursor Keys with controls on your form



Private Const WM_KEYDOWN As Integer = 256
Private Const WM_KEYUP As Integer = 257

Public Function PreFilterMessage(ByRef m As System.Windows.Forms.Message) _
As Boolean Implements IMessageFilter.PreFilterMessage

If (m.Msg = WM_KEYDOWN) Then
Dim keyCode As Keys = (CType(CType(m.WParam, Integer), Keys) And Keys.KeyCode)
'do your stuff with the key down here
'.....
Return True
End If
Return False

End Function

Private Sub FrmPortFolio_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
Application.AddMessageFilter(Me)
End Sub

End Class

Problems faced when dealing with DateTime field


Handling DateTime fields is sometimes annoying for beginners. The reason is the stubborn DateTime field. Chk this out;

Select [yourDateTimeField] From [TableName]
e.g. SELECT PostTime FROM ddl_log (select master first)

As you can see, time string always comes with the date. This thing gets even more irritating when we want date in its simplest most common form.

The point is, how to get hold of this DatType and mould it in our desired shape?

Lets take it step by step. First you fetch datetime from Sql and you get a value like '2009-12-10 23:18:44.923'. Question arrises;

Is there any ONLY DATE field in SQL?

The answer is no. You might be able to make a custom field using User-defined Data Types feature of Sql Server. In case if you dont do that, we come to the next step;

What do I do for the existing date fields that come with additional and unrequired time values

The answer is you Format them.
T-SQL gives rich string formating, at the cost of loosing original data type (but no loss of value)

Try this

Select Convert(Varchar, getDate(), 101)

What happened?? Isn't that something you just needed for which you looked so hard and finally came to this blog lolz.

What happened is that you see a date with the desired output. You can put your datetime field name in place of 'getDate()'

This function is tremendous to get the date in your desired format. Run the following queries and observe the changes;

Select Convert(Varchar, getDate(), 110)
Select Convert(Varchar, getDate(), 113)
Select Convert(Varchar, getDate(), 112)

Theres more to get as we share with you all the parameters that changes the datetime field in various usefull formats;

Date Time conversaion Table


1

Select Convert(Varchar, getDate(), 0)

Dec 24 2009 10:19PM

2

Select Convert(Varchar, getDate(), 1)

112/24/09

3

Select Convert(Varchar, getDate(), 2)

009.12.24

4

Select Convert(Varchar, getDate(), 3)

224/12/09

5

Select Convert(Varchar, getDate(), 4)

224.12.09

6

Select Convert(Varchar, getDate(), 5)

224-12-09

7

Select Convert(Varchar, getDate(), 6)

224 Dec 09

8

Select Convert(Varchar, getDate(), 7)

DDec 24, 09

9

Select Convert(Varchar, getDate(), 8)

222:19:31

10

Select Convert(Varchar, getDate(), 9)

DDec 24 2009 10:19:31:203PM

11

Select Convert(Varchar, getDate(), 10)

112-24-09

12

Select Convert(Varchar, getDate(), 11)

009/12/24

13

Select Convert(Varchar, getDate(), 12)

0091224

14

Select Convert(Varchar, getDate(), 13)

224 Dec 2009 22:19:31:203

15

Select Convert(Varchar, getDate(), 14)

22:19:31:203

16

Select Convert(Varchar, getDate(), 20)

22009-12-24 22:19:31

17

Select Convert(Varchar, getDate(), 21)

22009-12-24 22:19:31.203

18

Select Convert(Varchar, getDate(), 22)

112/24/09 10:19:31 PM

19

Select Convert(Varchar, getDate(), 23)

22009-12-24

20

Select Convert(Varchar, getDate(), 24)

222:19:31

21

Select Convert(Varchar, getDate(), 25)

22009-12-24 22:19:31.203

22

Select Convert(Varchar, getDate(), 100)

DDec 24 2009 10:19PM

23

Select Convert(Varchar, getDate(), 101)

112/24/2009

24

Select Convert(Varchar, getDate(), 102)

22009.12.24

25

Select Convert(Varchar, getDate(), 103)

224/12/2009

26

Select Convert(Varchar, getDate(), 104)

224.12.2009

27

Select Convert(Varchar, getDate(), 105)

224-12-2009

28

Select Convert(Varchar, getDate(), 106)

224 Dec 2009

29

Select Convert(Varchar, getDate(), 107)

DDec 24, 2009

30

Select Convert(Varchar, getDate(), 108)

222:19:31

31

Select Convert(Varchar, getDate(), 109)

DDec 24 2009 10:19:31:207PM

32

Select Convert(Varchar, getDate(), 110)

112-24-2009

33

Select Convert(Varchar, getDate(), 111)

22009/12/24

34

Select Convert(Varchar, getDate(), 112)

220091224

35

Select Convert(Varchar, getDate(), 113)

224 Dec 2009 22:19:31:207

36

Select Convert(Varchar, getDate(), 114)

22:19:31:207
Of course for the gurus and professionals, this might be a very ordinary post, dealing a very basic problem. But eventually for beginners like me, this is something which makes us halt for a while. And as I have experienced throughout my "Support" career , this would always come whenever setting a new machine for a web application on asp.net 2.0

Without any further delay, I am currently simply adding the 1 stop solution link to Microsoft website for the fix

http://support.microsoft.com/kb/555583
AJAX makes your UI more responsive, adding the richness in the application and Interactivity for the joy of end user. We have already moved from UI to User Experience now - Now we dont create UIs, we create Rich Interactive User Experience - FOr which one of the choice for the developers is AJAX. I will also highlight JQuery in t his regards but currently my focus is on AJAX.

I am implementing AJAX through MS AJAX Control Tollkit and AJAX Extensions. Not getting in any further techy details, the scheme is simple

We have a 'UpdatePanel', we have 'Triggers' and we have our code behind file whose code AJAX will call Aynchrosously.

At this point, I wanna tell you guys when i tried to start AJAX, it became so difficult for me because no resource on the internet actually defined straight away what this update panel has to do with AJAX. Actually i was a started from w3schools where you make the XmlHTTPRequest object, chk for browser compatibility, launch a request to a 3rd 'bridge' server page and then get your html result in your defined area. This was ok but not cool. Nothiung thats not pretty and also makes you work hard (for not much actually) is not cool i think.

So with all these contexts, whenever i tried to start AJAX control toolkit thing, I stucked in the update panel control not getting its purpose at all. More will be edited shortly, currently i have the following to share, yes once again, a link

http://webmaster-forums.code-head.com/showthread.php?t=885

At this page, you can get 10s of animated progress bars (gifs) to use with your update progress control. Along with thism i would like to mention the search  strings that are: 'progress', 'loading' and 'progess transparent'

As a starter, or a rather a moover (from WordPress) I have to share this beautiful link
http://www.pluralsight.com/main/olt/Module.aspx?a=fritz-onion&n=ajax-intro&cn=aspdotnet-ajax-fundamentals

They also provide Instructor Led (charged) and On-Demand trainings - + free stuff as well, regitser here, become a subscriber and get the benefits.
To get videos shared by MS asp.net site: http://www.asp.net/LEARN/ajax-videos/


and another 1 found on Gigapedia free: http://gigapedia.com/items:links?id=140056
top