Code Snippet Editor


Author
Message
Charles R Hankey
Charles R Hankey
StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)
Group: Forum Members
Posts: 524, Visits: 30K
This may fall into the category of "Well, duh!" but just in case anybody is lower on the learning curve than I am :

There is an extremely cool code snippets editor on the tools menu of VS.  Basically is adds stuff to intellisense.

I created a new folder for Strataframe snippets.  Here is an example of a Custom Field Property snippet

( this is instead of cutting and pasting from the bo.designer generated code as in the beginner tutorial. Note that the string datatype is hardcoded so either make a $replacement$ for it or remember to change it if your custom field prop isn't string Wink

#Region " Custom Field Properties "

''' <summary>

''' $Custom Field Description$

''' </summary>

''' <remarks></remarks>

<Browsable(False), _

BusinessFieldDisplayInEditor(), _

Description("$Custom Field Description$"), _

DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _

Public ReadOnly Property [$Property Name$]() As System.String

Get

Return $Property Value$

End Get

End Property

Protected Overrides Function GetCustomBindablePropertyDescriptors() As MicroFour.StrataFrame.Business.FieldPropertyDescriptor()

'-- Create and return a new array of FieldPropertyDescriptor

' objects that contains the ReflectionPropertyDescriptor

' for the $Property Name$ field.

Return New MicroFour.StrataFrame.Business.FieldPropertyDescriptor() { _

New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _

"$Property Name$", GetType($BOName$))}

End Function

#End Region

On the Imports tab you enter the stuff that must be imported for this to work

System.ComponentModel

Microfour.Strataframe.UI.Windows.Forms

For a shorcut I used cpr

Now if you are in the BO code, you just but the cursor under the Event Handlers region, type cpr, hit tab and everthing you see above gets typed in with the cursor on the first Replacement.  You fill it in, tab to the next one etc.

If the imports statements are not at the top of the declaration, the snippet editor puts them in !

I think this is cool and I'm pretty sure I've only scratched the surface of the possiblities here.

You may not see the Code Snippet Editor on the Tools menu ( for some reason mine didn't have it ) but if you Google you'll find it for download with easy instructions to install in.  Comes with a lot of predone VB stuff as well.

I've added

FillbyParam ( fbp )

Public Sub Fillby$Subname$(ByVal $param1$ As String)

'-- Establish locals

Dim loCommand As New SqlCommand()

'-- Build the query

loCommand.CommandText = "SELECT $Fieldlist$ FROM $tablename$ WHERE $param1$ like @$param1$+'%'"

'-- Add the parameter

loCommand.Parameters.Add("@$param1$", SqlDbType.NVarChar)

loCommand.Parameters("@$param1$").Value = $param1$

'-- Execute the command to fill the business object

Me.FillDataTable(loCommand)

End Sub Fillby$Subname$

MessageboxYesNo '

Dim dr As DialogResult = _

MessageBox.Show("$Message$","$Heading$", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)

If dr = Windows.Forms.DialogResult.Yes Then

End if

( sorry for the blank lines but I can't figure out how to turn off big line spaces after pasting code )

Would like to see what you guys who know a lot more about this stuff are doing with snippets  BigGrin

Charles

 

 

 


Reply
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Guess two steps forward one step back (tell me it's not the other way).

We too are from a VFP background and used to rely heavily on data dictionaries...which in our medical application we are doing everything that we can to get away from it!  There are better (and more efficient) ways of accomplishing the same thing in .NET.  One thing that most developers moving over from VFP have a hard time initially grasping is disconnected data.  When we were developing in VFP, you opened a table and BOOM...all of your records were there.  Even if you were using views it still had to bring the data to the client to do the work since there was not a server.

Relying heavily on a data dicitonary in a disconnected data application (which will be any application from this point forward) can create a slow and unresponsive application.  Thus most develpoers take a different approach.  It took us a while when we first stepped into .NET and disconnected data from VFP because we were trying to basically use the same techniques on a new technology....which just won't work...and it shouldn't.

I think that as you move forward you will discover hundreds of new things that will make your life much easier and better...so though at first glance it appears as though there has been a step back or two, that is just because we have generally been trying to look at it from the same perspective as when we were developing in VFP when there is ultimately a better and more efficient way in .NET.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search