please see image attached.
i want it to be
Public components As System.ComponentModel.lContainer
but every time I edit the form design, it always change back to its original code
Private components As System.ComponentModel.lContainer
You can have a public Property in your class that returns a private member, like yours. This code is generated by form designer and probably you can not change the behavior of this. Even if you could, I wouldn't suggest you to do this.
Public Class MyForm
Public Property Container As System.ComponentModel.IContainer
Get
Return Me.components
End Get
End Property
End Class
Cheers
Related
this is the class generated by the designer;
Partial Public Class fredTest
Public Property id As Integer
Public Property data As String
Public Property version As Integer
End Class
I'm trying to add the concurrency check by doing this;
<MetadataType(GetType(fredTestMeta))>
Partial Public Class fredTest
End Class
Public Class fredTestMeta
<ConcurrencyCheck>
Public Property version As Integer
End Class
and it doesn't work.
concurrency check does work if I use the designer to set it to fixed.
is it possible do make it work without playing with the designer?
If you are doing database first the concurrency needs to be set in the edmx file and this is what the designer does.
I have created a simple class like this one...
Public Class Localizer(Of T)
Public Shared ReadOnly Property DisplayName(ByVal propertyName As String) As String
Get
...
End Get
End Property
End Class
And I'm attempting to bind to it in XAML something like this...
Header="{x:Static loc:Localizer(Of AircraftReference).DisplayName [IsMilitary]}"
But this must not be the right syntax. This may not even be possible.
There are two problems here.
XAML support for generics is not complete; I don't think you can specify the type parameter in XAML.
However, there's an easy workaround for this problem:
Public Class Localizer(Of T)
Public Shared ReadOnly Property DisplayName As String
Get
...
End Get
End Property
End Class
Public Class AircraftReferenceLocalizer
Inherits Localizer(Of AircraftReference)
End Class
Now you can use:
Header="{x:Static loc:AircraftReferenceLocalizer.DisplayName}"
x:Static does not support parameterized properties, so you cannot pass the string "IsMilitary". I'm afraid you'll have to find a solution without x:Static. It might make sense to describe want problem you want to solve and ask for a solution in a new question.
I'm having some issues and it's all explained in some simplified code
I have a structure
Public Structure myStruct
Public Property name As String
Public Property span As Double
Public Property offs As Double
End Structure
Which is instantiated in a Singleton object as follow
Public myValues(10) As myStruct
Then on a form, I'm using the structure as the DataSource for a SourceBinder and the binder as DataSource for a DataGridView.
On loading the form, I get all the values into the binder
For i As Integer = 0 To 9
binder.Add(singleton.getRef.myValues(i))
Next i
All the values are shown on the grid.
User is supposed to be able to change the values, which should reflect on myValues but no matter, what code I put on CellValueChanged or CurrentChanged. I can't make it reflect the changes.
Using breakbpoints on those events, I noticed that grid.row().cell().values and binder.current never changes.
I tried also placing a button and directly changing myValues and reseting the binder binder.ResetBindings(False) and nothing happens.
As far as I saw all ReadOnly properties are set to false.
I've also tried setting VirtualMode to true on the grid and catching CellValuePushed and CellValueNeeded events but those are never called. (that was on a guessing base)
I'm really out of ideas on this one, if anyone can help me!
thanks.
Try using a class instead:
Public Class myStruct
Public Property name As String
Public Property span As Double
Public Property offs As Double
End Class
I'm building a webpart for Sharepoint 2010. I can create custom properties which are editable through the Sharepoint user interface. No problem there.
The problem is: I want to use a custom object(Properties.cs) to define those same properties(and keeping the editing functionality available), rather than dumping all code in the Webpart.cs like it's shown on the internet.
Is there a way to do this? Because I don't want to pump all my properties(editable or not) in the webpart class.
Yes, you can do it... by using inheritance and creating base classes as follows
1- first create a base class inheriting from WebPart class with override CreateChildControls method e.g
<XmlRoot("MyWebPartBase")> _
<ToolboxItemAttribute(True)> _
Public Class BaseWebPart
Inherits WebPart
Protected Overrides Sub CreateChildControls()
Dim control As Object = Page.LoadControl(ascxPath)
If control IsNot Nothing Then
control.WebPartControl = Me
Controls.Add(CType(control, Control))
End If
End Sub
'Add public properties here
End Class
2- Implement you properties in this base class and Inherent your webparts from above mentioned base class rather then webpart class.
3- Create a base class for user controls implementing public properties to access them in user control e.g.
Public Class BaseUserControl
Inherits UserControl
Private _WebPartControl As BaseWebPart
Public Property WebPartControl As BaseWebPart
Get
Return _WebPartControl
End Get
Set(ByVal value As BaseWebPart)
_WebPartControl = value
End Set
End Property
Public ReadOnly Property WebPartID() As String
Get
Return WebPartControl.ID
End Get
End Property
End Class
This is my first post on Stack Overflow so please exuse (and feel free to point out) any n00b mistakes.
I am trying to implement transactions across multiple TableAdapters in VB.NET (using Visual Studio 2010) by extending the partial class as described in the following examples:
http://blah.winsmarts.com/2006/06/18/the-definitive-tableadapters--transactions-blog-post.aspx
madprops.org/blog/typed-datasets-and-sqltransaction/
stackoverflow.com/questions/2342289/net-tableadapter-to-dataadapter
However, when I attempt to expose any of the private fields created by the designer they are underlined in the editor with the following error:
'_adapter' is not declared. It may be inaccessible due to its protection
level.
Searching this site as well as google has not revealed anything useful, but perhpas I'm searching the wrong keywords.
Here is the code in MyDataset.vb
Partial Public Class MyTableAdapter
Public Property MyTransaction() As SqlTransaction
Get
Return _adapter.SelectCommand.Transaction
End Get
Set(ByVal value As SqlTransaction)
If _adapter Is Nothing Then
InitAdapter()
End If
Connection = value.Connection
_adapter.InsertCommand.Transaction = value
_adapter.UpdateCommand.Transaction = value
_adapter.DeleteCommand.Transaction = value
End Set
End Property
End Class
and here is the designer code:
Partial Public Class MyTableAdapter
Inherits Global.System.ComponentModel.Component
Private WithEvents _adapter As Global.System.Data.SqlClient.SqlDataAdapter
Private _connection As Global.System.Data.SqlClient.SqlConnection
Private _transaction As Global.System.Data.SqlClient.SqlTransaction
Private _commandCollection() As Global.System.Data.SqlClient.SqlCommand
Am I missing something, or is this not possible in VB (all of the examples I've seen are in C#)?
TIA for any help!
JE
Can you access any Public properties/methods from the Adapter class?
I think you may have created your partial class in the wrong namespace. It has to be in Namespace MyDataSetTableAdapters