How To Support Setting Indexer Properties
Aug 29, 2011I created an indexer property by typing:Default Public Property MyStuf(ByVal anIndex As Integer) As String
View 3 RepliesI created an indexer property by typing:Default Public Property MyStuf(ByVal anIndex As Integer) As String
View 3 RepliesIn C# I can do this: public string myProperty { get; private set; }This is referred to as an "automatic getter/setter" (from what I've heard). Does VB.NET support these? So far, with my properties, all I can do is this:
[Code]...
Im having a problem with the XML in this function and many functions like it.Error XML axis properties do not support late binding.
Namespace
Imports Microsoft.VisualBasic
Imports System.Web
[code]....
seems to be where the error is occurring and I'm not quite sure how to fix it.
Looking at the new VB 2010 features, I stumbled upon support for Auto-Implemented Properties.Since I'm working with C#, this seemed quite familiar, but I noticed that VB did add a feature I would love to have in C#: setting a arbitrary default value for the auto-implemented property:I really like the clean usage of auto-properties in C#. This would save us the effort of introducing a backing field and hooking it up to the property everytime we simply need a default value, thereby cluttering up the code unnecessarily.I was wondering why this wasn't introduced in C# as well? What could be the rationale for not doing this? Is a syntax discussion going on, or are there technical limitations to implementing this?
View 4 RepliesI am basically from VC++, for compiling a project with Unicode support we will change the setting in project properties and build it. In VB.net is there anything like that, Do I have to change any setting before building to enable Unicode support.?
View 1 RepliesCan I create a class in VB.NET which can be used from C# like that:
myObject.Objects[index].Prop = 1234;
Sure I could create a property which returns an array. But the requirement is that the index is 1-based, not 0-based, so this method has to map the indices somehow:
I was trying to make it like that, but C# told me I cannot call this directly:
Public ReadOnly Property Objects(ByVal index As Integer) As ObjectData
Get
If (index = 0) Then
[Code].....
I have a property Cmd defined as follows
Private _cmd As ADODB.Command
Public ReadOnly Property Cmd() As ADODB.Command
Get
Cmd = _cmd
End Get
End Property
[Code]...
Can I change my property definition so that the user does not need the parens?
In the SignalR Chat sample, Caller properties are set using the code;
Caller.name = newUser.Name;
Then later on, this property is read;
string name = Caller.name;
I have my own SignalR project, but this one is vb.net, and when i do the same setting and getting of the Caller properties, it doesn't work
Public Sub SetCaller()
Caller.name = "tim"
End Sub
[Code].....
Did vs2008 or vb.net got some of the solution to solve properties setting of the components are same with each other?
Example: like I want to standard the datagridviews' property, each of the datagridviews' property is same with each other. but each time I create the new datagridview. I have to manually set the datagridview 1 by 1.
I've played around with this and have figured most of it on how to set the properties of most controls in the designer. I have 2 check boxes I need to set the values on but do not know how. 2 fields one for each in the db with a char(1) value, can be Y or N. If it a Y in the db how would I set it as checked on the form?
'cboPosition
Me.cboPosition.DataBindings.Add(New System.Windows.Forms.Binding("SelectedValue", Me.FmfieldmanmasterBindingSource1, "position_name", True))
Me.cboPosition.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.FmfieldmanmasterBindingSource1, "position_name", True))
[Code] .....
I'm stuck trying to figure this one out. I am trying to set a GridViews Column properties by using reflection and the Extended properties off a DataTable.the Code looks something like this
Dim colproperty As PropertyInfo = gv.Columns(col.Ordinal).GetType.GetProperty(key)
Where key = "ItemStyle"
So I get the ItemStyle Property by I'm unsure how to set the next varibel which would be BackColor:Red in the collection i have that key access. This is all text.in the XML the extendedproperty is set like this
msprop:ItemStyle="BackColor:Red"
I can easily set all of the attribues for a gridview using something simular to this but of course gridview columns do not have attributes only properties.
Gridview attribute setting code
Dim nvCollection As PropertyCollection = table.ExtendedProperties
For Each key As String In nvCollection.Keys()
Dim colproperty As PropertyInfo = labelOut.GetType().GetProperty(key)
[code]....
I am trying to get some objects invisible as I fill a dialog, but it doesn't work when coding from the dialog.
how to get this code working
ProductTypeIdtext = "0"
SingleLineTransfer.grnuminfoPSTN.Visible = True
SingleLineTransfer.grwholesale.Visible = True
[Code].....
is there any trick (because I can't think of anything else ! ) to massively set all of the properties , of a user defined class , to their null values ? You see , I have a class called Apartment and it has a lot of properties (it only has properties , no methods or events , if that's important) and those properties are either strings , doubles or integers . I want each time I create a new instance of that class (a new apartment , that is) to automatically set those properties to their null values . That is all of the strings to be equal to "" and all of the numbers to be equal to 0 . Back in VB6 I could rely on VB6 to do this automatically , but now in VB .NET , whenever I create a new instance of a class , all the properties start with the value = Nothing . I know I can define every property in the class module like that : Public MyVariable As String = "" but I'd like to keep them as they are and set their null values directly whenever a new object of that class is created .
View 8 RepliesMost of the apps I write have a base / home form and a few other forms (three of four typically) which pop up in response to controls clicked by the user. I'd like to be able to set some properties to be the same for all the forms in an app; particularly properties like BackColor and FormBorderStyle. Yes, I can manually set the individual properties for each form in the VB IDE, but I'd prefer to be able to have one line of code in the base / home form for each property along with one line for each dependent form which says something to the effect of "use the same property value as the base / home form has". Overall, my objective would be to have one single line of code in the app which, when changed, would apply the changed property to all the forms. For example, a single line which I can change to take the BackColor from Apple to Orange for all the forms ...
[Code]....
In VB6 I would simply retrieve the user font setting from the .ini file, load into variables and then apply to the appropriate control.
text1.fontbold = userfontbold
text1.fontitalic = userfontitalic
text1.fontunderline = userfontunderline
etc.
I'm struggling to understand how to do this vb.net The following code works, but sets all three at one time
Text1.Font = New Font("Courier", 10, FontStyle.Bold Or FontStyle.Italic Or FontStyle.Underline)Since the user can have many different combinations of settings, I would like to be able to add just one of these properties at a time, but can't seem to figure out how to do it.
I have a icon for my application that I set in the project properties window there is a little drop down box to browse to the icon location. While debugging everything is good. Once I build the app and place it on a PC and manually start the app all is good. My app starts with windows and now every time the program goes to start I get an error that the icon cannot be found in the DocumentandSettingUSERNAME folder. So the question is do I have to place my app icon in this folder? In design I have the icon in the binDebug folder and that is were I point to in the Project properties page.
I am using VS 2008 VB.net.
i am writing a VB front end (VS 2008 .NET 3.5) to a data loading program that involves moving the contents of CSV flat files into SQL Server 2005 staging tables. I have had some experience with DTS in SQL 2000 so I decided to use SSIS packages to load the CSV data. Creating the packages in BIDS worked fine for the development environment where I hard-coded the Connections and file paths. The problem arises when I will release this program to 30 different sites that do not have SQL Server admins to help changing the configuration.
I have a SQL table in which I will put all the necessary path information and I can pull that into the VB program on startup. I need to see an example of how I can set the properties from VB once the package is instantiated and opened.Here is an example of where I plan to set those properties and run the packages.
Private Function RunPackages() As Boolean
Try
Dim oApp As New Application
Dim oPackage As New Package
[code]....
Even though I am using a configuration file in the example, I am finding it difficult to edit the configuration files for each site. I see that there are methods and properties exposed for the oPackage instance. However, I can't find a good reference for the Class model to use as a guideline. All the examples expect packages to be run and configured with SQL Server and BIDS. direct manipulation of package properties in VB or C#?I am now considering using the old standby SQL Bulk Insert. It almost appears as if the Data Tasks are just wrappers for the Bulk Insert operation. Furthermore we have several sites still using SQL Server 2000. With the economy the way it is, most of those sites do not want to spend ANY extra money upgrading to SQL 2005 or 2008.
However, having a good resource to learn how to manipulate SSIS packages from the CLR would be very helpful. I have heard that in SQL 2008 things have changed even more. It is maddeneing that once I learn a "new" Microsoft technology it seems to be discarded by MS in their next release in favor of a "better" alternative.
I have a DetailsView which has two fields - one that is visible, one that is not. The first the user fills out, the second I want to auto-populate. Unfortunately, I haven't been able to find a way to set the value in this second invisible field. I've tried adding code like this to the Page_Load:
If Not IsPostBack Then
DetailsView1.DefaultMode = DetailsViewMode.Insert
Dim txt1 As TextBox = DirectCast(DetailsView1.FindControl("Type"), TextBox)
txt1.Text = "administrator"
End If
But this returns an error of "Object reference not set to an instance of an object." Any ideas on how to accomplish this - either using the method above or another method?The hoped for end result is that when a new record is inserted via the DetailsView that this record will include the username (entered by the user) as well as the "type" of "administrator"
I have built a deployment program (vS 2008 Standard Edition) and tried to set the Properties column to a product name and company. I have also tried leaving these blank. I'm really trying to configure my setup.exe so that it installs by default in Program FilesMyFolderName without adding a subdirectory to the path. Is there somewhere I can specify exactly the default path for my setup without it adding a subdirectory? What do I edit?
View 2 RepliesI need to work with custom controls, I want to be able to set the properties of my controls so when I put them on my windows forms they will show up in the properties window thing.
View 3 RepliesI'm making an editor for my app. which allows the user to change properties of the controls including the font.I'm storing the values in a collection but I'm having trouble re-setting the fontstyle from the stored value. I'm storing the font information like so...
FontString = SpeedGroupbox.Font.Name & "|" & SpeedGroupbox.Font.Size & "|" & SpeedGroupbox.Font.Style
EditedControlsCollection.Add(FontString, "SpeedGroupbox.Font")
is it possible to set a value of an item, for example: a textbox1.text = Empty.String at design time?
View 5 RepliesI compiled some VB6 code on my Win7 x64 machine and the result .exe will not run correctly on any other machine. VB6 code is just a new template .exe file with one button, a reference to "Microsoft ActiveX Data Objects 2.6 Library" and the following code in the button press event: Dim db Set db = New ADODB.Connection It runs correctly on my machine, but no others (even other Win7 x64 machines) (Update: I found TWO other users where it runs and one of them is Jeff Atwood!, but most machines have the same problem)
[Code]...
I am using a PropertyGrid control to edit my class properties and I am trying to set certain properties read-only depending on other property settings.This is the code of my class:
Imports System.ComponentModel
Imports System.Reflection
Public Class PropertyClass[code].....
This is the code I am using to edit the values:
Dim c As New PropertyClass
PropertyGrid1.SelectedObject = c
The problem is that when I set SomeProperty to True, nothing happens and when I then set it to False again it sets all properties Read-Only.
this.label39.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label39.Location = new System.Drawing.Point(37, 303);
this.label39.ForeColor = System.Drawing.Color.Black;
[code].....
I have a usercontrol that has a main form and calls another form within the usercontrol to get some data from a database that allows the user to select some items from a CheckedListBox control on the sub form. I want to pass the selected items from the CheckedListBox back to the main form and display the results there. I have a public property called DBList of type List(of String) on the main user control. If I create a reference to the usercontrol form the second form within the usercontrol I get a new instance of a user control. All I want to do is set the property on the usercontrol and close the secondary form. How do I reference the usercontrol from the form within the usercontrol?
Code in UserControl:
Public Property DBItems() As List(Of String)
Get
Return DBItems
[Code]....
I need help and wondering if you can help me to get my first project...it's a hobby and wondering if you can get me code for this so i can see how it does it* Evaluate( ) Prints the evaluation of the hand to the evaluation Label.
o If IsFlush( ), prints "flush; "
o calls SetPipArray( )
o Uses a For Loop to go through pipArray. For each element, uses a Select Case statement to
[code]....
[code]I want to make the Properties Window to update the properties for X and Y at each MouseMove, so they become immediately visible for the user.
View 2 RepliesI'm making a control and I am trying to finalize my design time properties grid. I have several List(of Class) items as public properties and when I click on the design time menu (while testing the control) there is the word "Collection" and a button with an ellipsis (...) that brings up a neat pop up with the buttons Add/remove and all of the public properties of the collection's class on the right hand side. Basically for a non-collection instance of a class (with public properties) I'd like a similar button to show up. I know I could put all of the properties in the main control class and group them, but I like the pop up box feature. Anyway to duplicate this? (think font grid item etc.)
View 3 RepliesIn the form design I set up a TableLayoutPanel, 20x20 cells and in cell (1,1) a PictureBox (called Target) containing the image of a small target. The properties box for Target shows some very promising properties, Column and Row - and if you overwrite the values in the properties box, the PictureBox obligingly shifts to the corresponding cell position in th design. However in VB it is not possible to refer to Me.Target.Row or .Column - neither appears during coding in the menu of properties, and deliberately coding either of them produces an error like
Error 1 'row' is not a member of 'System.Windows.Forms.PictureBox'.
1. Why does the properties box show properties that cannot be altered programmatically?
2. How can my program move Target around in the TableLayoutPanel?