473,385 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Can VS.net generate properties

is there a way to automatically generate properties from fields in
vs.net

Nov 21 '05 #1
2 1272
<jw*****@gmail.com> schrieb:
is there a way to automatically generate properties from fields in
vs.net


There is no built-in way to do that, but you can write your own add-in/macro
to create the property or use 3rd-party add-ins which support that.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2
No, but if you use a simple recorded macro you can save the macro for later
use. I just recorded this one directly from the keyboard using the
Ctrl+Shift+R hot-key combination. As you can see, it grabs the field name,
modifies it, pastes in extra bits and creates a property. It uses my
standard of naming fields with an underbar and an initial lower-case letter
so that for example a field named "_foo" creates a property named "Foo"

Sub VBFieldToProperty()

DTE.ActiveDocument.Selection.EndOfLine()

DTE.ActiveDocument.Selection.StartOfLine(vsStartOf LineOptions.vsStartOfLineOptionsFirstText)

DTE.ActiveDocument.Selection.WordRight()

DTE.ActiveDocument.Selection.WordRight(True)

DTE.ActiveDocument.Selection.Copy()

DTE.ActiveDocument.Selection.EndOfLine()

DTE.ActiveDocument.Selection.NewLine()

DTE.ActiveDocument.Selection.Text = "public property "

DTE.ActiveDocument.Selection.Paste()

DTE.ActiveDocument.Selection.WordLeft()

DTE.ActiveDocument.Selection.Delete()

DTE.ActiveDocument.Selection.CharRight(True)

DTE.ActiveDocument.Selection.ChangeCase(vsCaseOpti ons.vsCaseOptionsUppercase)

DTE.ActiveDocument.Selection.EndOfLine()

DTE.ActiveDocument.Selection.LineUp()

DTE.ActiveDocument.Selection.EndOfLine()

DTE.ActiveDocument.Selection.WordLeft(True, 2)

DTE.ActiveDocument.Selection.Copy()

DTE.ActiveDocument.Selection.LineDown()

DTE.ActiveDocument.Selection.EndOfLine()

DTE.ActiveDocument.Selection.Paste()

DTE.ActiveDocument.Selection.NewLine()

DTE.ActiveDocument.Selection.Text = "return "

DTE.ActiveDocument.Selection.LineUp(False, 3)

DTE.ActiveDocument.Selection.StartOfLine(vsStartOf LineOptions.vsStartOfLineOptionsFirstText)

DTE.ActiveDocument.Selection.WordRight()

DTE.ActiveDocument.Selection.WordRight(True)

DTE.ActiveDocument.Selection.Copy()

DTE.ActiveDocument.Selection.LineDown(False, 3)

DTE.ActiveDocument.Selection.EndOfLine()

DTE.ActiveDocument.Selection.Paste()

DTE.ActiveDocument.Selection.LineDown(False, 3)

DTE.ActiveDocument.Selection.EndOfLine()

DTE.ActiveDocument.Selection.Indent(2)

DTE.ActiveDocument.Selection.Paste()

DTE.ActiveDocument.Selection.Text = "=value"

DTE.ActiveDocument.Selection.LineDown()

DTE.ActiveDocument.Selection.LineUp()

DTE.ActiveDocument.Selection.NewLine()

DTE.ActiveDocument.Selection.LineDown()

DTE.ActiveDocument.Selection.LineUp(False, 3)

End Sub
--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

<jw*****@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
is there a way to automatically generate properties from fields in
vs.net

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Lut | last post by:
Hey, I made a custom usercontrol (Custom listview) in the Control Library. Now I want in the properties of design a property 'Sort'. (That is not a problem to do that) But, when it is Yes...
1
by: | last post by:
please help me!
1
by: A Traveler | last post by:
Hello, i am having this problem. The exact error message is: "Unable to generate code for a value of type 'System.Web.UI.Page'. This error occurred while trying to generate the property value for...
1
by: Alexander Kaplunov | last post by:
I have a web service, which has a reference to a class. I want to be able to accept this class as a parameter to my web service method. When the consumer consumes the web service, proxy class is...
8
by: Bill Rust | last post by:
I've created an "Add Item" wizard for VB.NET 2003 that allows a user to add a specialized class that works with my application framework. In the wizard, the user can select the interfaces they...
7
by: Sharon | last post by:
I'm writing my own control that derived from the UserControl. In my control I have some public properties (with get and set) that I do not want them to be shown on the designer properties window...
1
by: Carl Johansen | last post by:
Hi all, I have an ASP.NET 2.0 website in Visual Studio 2005 (ie I open it with File | Open Web Site...). I have put XML comments in the source code in the App_Code directory (with <summary>...
0
by: TN | last post by:
I created a dataset in code (with extended properties on the table and the columns) and I saved the schema (the properties were there). Now I am trying to take that .xsd file and generate a...
2
by: bthubbard | last post by:
This may not be the best group in which to post this. If there is a better location please direct me there. I have been experimenting with Sandcastle to generate CHM help file documentation for...
7
by: =?Utf-8?B?TXJOb2JvZHk=?= | last post by:
I am used to using Java's Eclipse IDE where I can choose one or more fields and have the IDE automatically generate getter and setter methods for it. Is there something in the Visual Studio IDE...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.