How To Use / Implement .NET Controls/interfaces
Aug 25, 2011
I am a VB programmer of some 13 years. I started briefly with VB5 back in the mid-to-late 1990s, but then quickly moved to VB6 which I did for several years on PCs and HPCs (CE 1.x devices).I have done .NET 2002, 2003, 2005, and 2008 each for stints, intermingled with VB6 coding, at various jobs. But, I never got formally trained on VB.NET. In fact, I taught myself VB5/6 too. I have a degree in Computer Science and Mathematics, but the university CS program only had Unix systems. I basically learned everything I know on the fly from various Microsoft Press and other company's books (and the MS website/MSDN CDs too) while doing projects.I was wondering what everyone would suggest to really learn the .NET workings and why they are setup like that for Windows client/server applications. It doesn't have to be technical and brain-numbing.I have recently run into things dealing with MSFlexGrid vs DataGridView and how they link/work with database sources that confounds me. And, I am assuming there's just something I don't know about how/why VB.NET works the way it does...and I want to learn it to become a better developer.I want kind of that fun book that's easy to read, is thorough in that it teaches you a wide range of how to use/implement .NET controls/interfaces, and will fill in the gaps in my knowledge and experience.
View 1 Replies
ADVERTISEMENT
Nov 3, 2010
I have an interface called IBaselineControl. Now I'm trying to write a procedure which requires, as an argument, a Control which implements the IBaselineControl interface. However, I don't know the syntax for this. VB.Net allows us to require multiple interface implementations along with class inheritance when writing constraints for generic types. The syntax used there suggests that something like this might work:Public Sub Test(X As {Control, IBaselineControl})Unfortunately, that syntax doesn't work and I'm unable to find any syntax which does.
View 6 Replies
Nov 26, 2009
I have an interface IMyInterface and this interface implements a method MyMethod.I have an object MyObjectBase. This object contains a(the same) method MyMethod.1) If now I do MyObject Inherits MyObjectBase Implements IMyInterface need I to redefine? (shadow, override) MyMethod in the MyObject class?
View 2 Replies
Dec 15, 2011
Can any one explain the usage of interfaces to implement multiple inheritance in VB.NET.
View 6 Replies
Jan 15, 2010
I typically dont create interfaces unless i have to, however in my current application i have to create interfaces in the Data access layer. I'm a in a minor confusion that hwo do i create those interfaces more how to implement them: the following code might make things clear:I have the following class and interface in the data access namespace
[code="vb"]Imports ConsoleApplication8.BusinessLayerImports ConsoleApplication8.DataAccessLayerImports System.DataImports System
Namespace DataAccessLayer
Public Class CountryGateway Implements ICountryGateway
[code]....
1. Is this way implement the interface in the data access layer? (in this case the class CountryGateway access the database.)
2. I have been told that we should create interfaces than abstract classes espcially in the data access layer, is there a particular reason for this?
View 9 Replies
Oct 16, 2009
Are Interfaces used often? Need opinions.
View 4 Replies
Mar 13, 2009
I have the following problem with MEF: Interface definition to be used by host:
Public Interface IExecuteDoSomething
Inherits IAddinSettings
Event DataReceived As EventHandler(Of DataReceivedEventArgs)
Function DoSomething() As Boolean
End Interface
[Code]...
Everything seems to work fine until the Button2_Click routine is executed, then an InvalidCastException is thrown with the info:Unable to cast object of type 'System.Collections.Generic.List1[SharedLibrary.IExecuteDoSomething]' to type 'System.Collections.Generic.List1[SharedLibrary.IAddinSettings]'.
How can i solve this problem, because the imported object implements both of the interfaces?
View 1 Replies
Dec 30, 2011
In this discussion let us discuss every usage of interfaces in .NET. Any real time examples and difficulties in using interfaces can also be discussed here.
View 6 Replies
Aug 6, 2009
Im building a game with VB.NET I designed the core of the game in form1 window But now I need menus. How can I implement this without having 5 or so windows that I show() and hide() ? Doing that slows it down a lot and uses lots of memory. I tried tabs, but I don't want the tabs to appear, just switch. Whats the best way to implement multiple interfaces?
View 1 Replies
Jul 14, 2011
Has someone a hint what I'm doing wrong in VB.Net?
Module Module1
Interface ISearch(Of T As ISearchResult)
Function ids() As List(Of T)
End Interface
[CODE]...
The third cast isn't working. Why? did I miss a oop lesson?
View 2 Replies
Sep 12, 2009
What I would like to do is make an abstract class that will hold objects in a dictionary and manage the adding/deleting/key changes of those items in the dictionary. My problem is that in order to make the class as generic as possible I declared the dictionary as dictionary(of long, of SomeInterface).The problem is when I try to pass a strongly typed dictionary in the constructor using dictionary( of long, ClassThatImplementsSomeInterface) I get a compiler error because it cannot convert to that type.
The reason I want to pass the dictionary in the abstract class's constructor is so that I can use the strongly typed dictionary in the subclass and have the abstract class manage the keys when it needs to. So how can I do something like this? Also- If there is a much better way to manage keys than what I am doing feel free to let me know, but I am much more interested in how to make this work since I have encountered this type of problem a few times before.
Here's the abstract class:
Public MustInherit Class HasChildrenKeys
Protected m_childItems As Dictionary(Of Long, IHasKey)
[code].....
View 7 Replies
Oct 20, 2011
I have a solution with multiple projects, some of the projects are written in VB, some in C#. I am wondering if there's a way to use interfaces and/or enums written in VB in C# classes? My C# code below doesn't compile, however I am able to see the interface in intellisense.
[Code]...
P.S It's a console/service application, not ASP.Net (where I know it's doable).UPD: Sorry guys, was missing a reference to the project with the interface. It's fixed now. I think the thing that in VB projects references are done slightly different than in C# confused me.
View 2 Replies
May 1, 2009
I have a program written in Visual Studio to me 3 values ( 0-255, 0-255, 0-255) to send the serial interfaces, and While assigned to the 3 values of 3 sliders together.[code...]
View 1 Replies
Nov 14, 2010
Say I have a interface called IProperties and I have a collection called colMyProperties that is a collection of IProperties. Then I have an object called clsProperty that implements the IProperty interface. Now, in my code where I add objects to the colMyProperties collection I add a bunch of clsProperty objects. so far so good.
Now when I try to access an object in the collection I can only access properties and methods of the IProperties interface, not the clsProperty object. What am I doing wrong? Do I need to cast the object?
View 2 Replies
Oct 4, 2011
I have a project that has several different interfaces (a website, a local application, and some webservices), that all use the same class library. The library is an API to a database. Some settings, like log level, database connection etc, i want to store in a single place, and I want them editable. What is the best way to accomplish this? I am concerned both about ease of editing, and ease of access for the dll, as there will be a lot of calls to it and a lot of lookups for the values. I have considered using app.config, a standalone XML file, and writing values to the registry, but I cannot find any good comparisons.
View 2 Replies
Dec 8, 2009
I have three classes which implement an Interface iComparesWith, and I wish there to be a single function such that each iComparesWith object of any of the three implementing classes should be able to compare itself with any other iComparesWith object, again, of any of the three implementing classes, and know if the two objects are equal. How can I code this so that the comparison code is only written once? Is it the case that I will have to create a top-level MustInherit class which implements the equality comparison, and have MustOverride methods for all of the methods of iComparesWith?
View 1 Replies
Jul 5, 2010
I am working on creating a customized UI composite control. This control would be a container to several other custom controls.As a first step, i am creating the container UI using a singleton pattern. This is because at any point in time only one isntance of this container is allowed to be created. This is fine.Now i want to practice interface based desgin. So i introduced a sinple interface calleD IdesignSurface which has two properties. I would like my singleton class to implement this interface,so i tried something like this and got an error saying "end of line
NotInheritable
Class DesignSurface
implements IDesignSurface
[code]......
View 2 Replies
Apr 21, 2010
When I pass an an object 'MyObject' which implements 'IMyInterface' to a method parameter declared as IMyInterface, I understand that this method parameter 'sees MyObject through the eyes of its interface'.
View 2 Replies
May 8, 2010
Can we call firewall an interface?
View 1 Replies
Mar 13, 2011
Is is possible to implement a type specifier with 2 interfaces in .net? Something like:
Public Sub New(obj as ICollection and INotifyCollectionChanged)
''Initialize Code
End Sub
View 2 Replies
Apr 22, 2011
I have a Delphi written DLL that exposes some interfaces to a vb.net application.
The interfaces inherit from IUnknown (but this could be changed if required), simplified example:
IWindow = interface(IUnknown)
['{E9A11D0B-8A05-4CBA-83FA-C5CC6818DF6E}']
function GetCaption(var Caption: PChar): HRESULT; stdcall;
end;
[Code]....
Now I want to transfer a collection of IWindow to vb.net, and in the vb.net application I want to be able to loop through it with a for in loop.
I read that it's possible using IEnumerable/IEnumerator but I don't quite understand how to implement them. Are there any good tutorials about this, specifically showing the declarations on both side? Example code would be great.
Please note that I prefer not create a com dll that should be registered and imported. Currently I export a function that enabled me to obtain an interface.
View 1 Replies
Oct 17, 2011
how to do something that seems that it should be simple.
I tried it on a larger project I'm working on and got an error, so I reduced it to the simplest possible that I could find:
Public Interface IF1
Event WakeUp(ByVal TheObject As Object)
End Interface
[Code]....
View 3 Replies
Apr 9, 2009
I just started playing around with interfaces recently and I have a couple things I want to ask. First off I always understood that an Interface cannot contain code, you are merely creating almost a "template" of methods, property's etc...Lets say I have this:
Public Class MyTest
Implements IMyTest
Public Sub iDispose() Implements IMyTest.iDispose
[code].....
View 3 Replies
Jan 8, 2010
I have the following code compiles without issue. Of course, I get an invalid cast xception when executing the Dim C As IDoThingsC = GetThing_C(). Am I missing something?Would you ever want to return an object that does not meet the interface requirement for a function return value?
Public Class ClassA
Public Sub DoThings_A()
Debug.Print("Doing A things...")
[code].....
View 3 Replies
Jan 19, 2010
is there any reason why we couldn't add/extend an interface to an already existing class?
i believe this would be v useful. it would be like drawing links from my class to already existing classes, and drawing links from already existing classes to already existing classes
View 8 Replies
May 7, 2012
I am looking for a way to add an interface implementation to a class at runtime.
Here is a sample code, which I will discuss below.
Public Interface IAction
Sub DoThis(a As Integer)
End Interface
[Code]....
This is related to WCF, where one needs to provide to CreateHost a single class, which implements all interfaces required for the end points. In this scenario, ActionDispatcher is such a class, and IAction is one of the many interfaces to be implemented.
My vision is to avoid implementing IAction in ActionDispatcher manually, but have some sort of registration mechanism, where I can say, that ActionDispatcher must implement interfaces IAction, IDoing, INoAction, etc - and have the dispatching methods generated for me.
MSDN says, that any class is compatible with any interface, so I don't need to declare "Implements" in the ActionDispatcher. But I still need to implement the interface and connect the implementing method to the interface definition, so WCF can find it when needed.
The closest thing I found is probably the Automatic Interface Implementer, but it (1) creates a new type, (2) adds dummy methods.
I has also tried to understand CodeCompileUnit class, but so far couldn't see the relation to what I need.
View 4 Replies
May 13, 2010
I am developing a web app but is not satisfied with is architecture that I am following. The architecture is plain old conventional 3 tier architecture. What i want is follow some design pattern or architecture that will be help me in decoupling my code.I have idea about MVC and MVP architectures for Web App but i need different from that. I want to use OOPS concepts using abstract classes and interfaces, polymorphism etc in my app but not MVC and MVP. I dont know why?
View 2 Replies
Mar 8, 2012
I am trying to make a plugin system in vb.net and i am using interfaces to do that. I have managed to implement the plugins but now i am having problems with setting the plugins in a dictionary or some sort of array.
The system is simple. I have the main application and i have plugins. The application needs 2 mandatory plugins and that is data and authentication. Other plugins are free to use so i have 3 interfaces. Data, Authentication and CustomPlugins.
I load the plugins with this
CODE:
It works fine like this but i want to make a collection of plugins because i don't know how many plugins the customer make. So initially i thought to make a collection
CODE:
But that doesn't work. The main focus is to load as many plugins as i like but have then in some sort of array. A dictionary would be perfect but is not a must.
View 2 Replies
May 6, 2010
I want to define a variable that is a collection of interfaces - it could be any interface that is defined for use in my app.
e.g. Dim x as New List(Of InterfaceBase)
Is there a base type for all interfaces that I can use for InterfaceBase?
View 1 Replies
Feb 8, 2012
I came to the point where I have to clone a complex data structure. During this process, cloning an object multiple times must be avoided, and circular references must be considered. I already have a working solution for this:
Friend Interface ICloneable(Of T As {Class, ICloneable(Of T)})
Function Clone(ByVal CloneMap As CloneMap(Of T)) As T
End Interface
Friend MustInherit Class CloneMapBase(Of T As Class)
[code]....
View 3 Replies