Search Results

Search found 1493 results on 60 pages for 'inheritance'.

Page 24/60 | < Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >

  • How can I make datagridview can only select the cells in the same column at a time?

    - by MemoryLeak
    I am using winforms to develop my application. And I set my datagridview control's selectionmode to "CellSelect", and this allow the user to select as many cells as he want which spread over several columns; but I want to constraint my user can only select cells in single column at a time, and there isn't any such kind of selectionmode for me. So If I want to implement this, how can I extend the datagridview class ? I also think that I can check in eventhandler whenever the selection cells are changed, through which I might make the user can not select cells spread over multiple columns, but this is not that good, I think. Can any other people help me to find out a better solution ?

    Read the article

  • ASP: Extend control (ASCX) and access base markup file from subclass code

    - by Pathoschild
    Hello, I'm building form validation controls for our C# ASP application. The bulk of the work is handled by a BaseValidator control (subclassing System.Web.UI.UserControl), which also has the markup for the validation output. This is then extended by subcontrols like PasswordValidator, that provides the Validate method and any extra fields needed by that validator control. (The end goal is to have controls like <uc1:PasswordValidator ControlId="txtPassword" /> which we can plop into any form with minimum duplication.) However, PasswordValidator.ascx.cs cannot access the form elements defined in BaseValidator.ascx; the only way I've found to do so is to duplicate the markup in each subcontrol's *.ascx file. How can I extend BaseValidator.ascx.cs and access BaseValidator.ascx's markup in the subclass?

    Read the article

  • Inheriting from class that inherits from DynamicObject

    - by SeveQ
    Hello there, I'm experimenting with C# 4.0's dynamic object model. I've created an abstract class named "Block" that inherits from DynamicObject. It overrides TryGetMember and TrySetMember. Furthermore I've created a usable class named "Brush" that inherits from "Block". I want it to be usable dynamically. But when I create a dynamic object from it and try to access a runtime bound member, it pelts me with an exception telling me that the member doesn't exist. The overridden TryGetMember or TrySetMember methods of the abstract parent class aren't getting called. Is this behaviour to be expected? Thank you!

    Read the article

  • ASP.NET Model Binder and base type

    - by user137348
    My model inherits from an interface: public interface IGrid { ISearchExpression Search { get; set; } . . } public interface ISearchExpression { IRelationPredicateBucket Get(); } The model: public class Project : IGrid { public ISearchExpression Search { get; set; } public Project() { this.Search = new ProjectSearch(); } } The ProjectSearch: public class ProjectSearch: ISearchExpression { public string Name { get; set; } public string Number { get; set; } public IRelationPredicateBucket Get() {...} } And the strong typed partialview in the main view: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ProjectSearch>" %> <%= Html.TextBoxFor(x=>x.Name)%> <%= Html.TextBoxFor(x => x.Number)%> .... When I submit the form, the Search property don't get bound properly. Everything is empty.The action takes an argument of ProjectSearch type. Why the Search don't get bound as supposed ?

    Read the article

  • sti and polymorphic's

    - by Alexey Poimtsev
    Hi, I have problem with my code class Post < ActiveRecord::Base end class NewsArticle < Post has_many :comments, :as => :commentable, :dependent => :destroy, :order => 'created_at' end class Comment < ActiveRecord::Base belongs_to :commentable, :polymorphic => true, :counter_cache => true end And on attempt go get comments for some NewsArticle i see in logs something like Comment Load (0.9ms) SELECT "comments".* FROM "comments" WHERE ("comments"."commentable_id" = 1 and "comments"."commentable_type" = 'Post') ORDER BY created_at Strange that "commentable_type" = 'Post'. Whats wrong? PS: Rails 2.3.5 && ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-darwin10]

    Read the article

  • STI and polymorphs

    - by Alexey Poimtsev
    Hi, I have problem with my code class Post < ActiveRecord::Base end class NewsArticle < Post has_many :comments, :as => :commentable, :dependent => :destroy, :order => 'created_at' end class Comment < ActiveRecord::Base belongs_to :commentable, :polymorphic => true, :counter_cache => true end And on attempt go get comments for some NewsArticle i see in logs something like Comment Load (0.9ms) SELECT "comments".* FROM "comments" WHERE ("comments"."commentable_id" = 1 and "comments"."commentable_type" = 'Post') ORDER BY created_at Strange that "commentable_type" = 'Post'. What's wrong? PS: Rails 2.3.5 && ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-darwin10]

    Read the article

  • "Undefined Symbols" when inheriting from stdexcept classes

    - by Austin Hyde
    Here is an exception defined in <stdexcept>: class length_error : public logic_error { public: explicit length_error(const string& __arg); }; Here is my exception: class rpn_expression_error : public logic_error { public: explicit rpn_expression_error(const string& __arg); }; Why do I get this error when <stdexcept> does not? Undefined symbols: rpn_expression_error::rpn_expression_error(/*string*/ const&), referenced from: ... ld: symbol(s) not found

    Read the article

  • Calling function using 'new' is less expensive than without it?

    - by Matthew Taylor
    Given this very familiar model of prototypal construction: function Rectangle(w,h) { this.width = w; this.height = h; } Rectangle.prototype.area = function() { return this.width * this.height; }; Can anyone explain why calling "new Rectangle(2,3)" is consistently 10x FASTER than calling "Rectangle(2,3)" without the 'new' keyword? I would have assumed that because new adds more complexity to the execution of a function by getting prototypes involved, it would be slower. Example: var myTime; function startTrack() { myTime = new Date(); } function stopTrack(str) { var diff = new Date().getTime() - myTime.getTime(); println(str + ' time in ms: ' + diff); } function trackFunction(desc, func, times) { var i; if (!times) times = 1; startTrack(); for (i=0; i<times; i++) { func(); } stopTrack('(' + times + ' times) ' + desc); } var TIMES = 1000000; trackFunction('new rect classic', function() { new Rectangle(2,3); }, TIMES); trackFunction('rect classic (without new)', function() { Rectangle(2,3); }, TIMES); Yields (in Chrome): (1000000 times) new rect classic time in ms: 33 (1000000 times) rect classic (without new) time in ms: 368 (1000000 times) new rect classic time in ms: 35 (1000000 times) rect classic (without new) time in ms: 374 (1000000 times) new rect classic time in ms: 31 (1000000 times) rect classic (without new) time in ms: 368

    Read the article

  • Refactoring a C# derived class with method dependancies

    - by drelihan
    Hi Folks, I want to get your opinion on this. I have a class which is derived from a base class. I don't have control over the code in the base class and it is critical to the system that I derive from it. In my class I inherite two methods that are critical to the system and are used in pretty much every function, many times. I intend to refactor this derived class and extract some classes from it - this won't be a problem. What I'm not sure about is, is it worth extracting class if I have to constantly make call backs to my main class to access the two methods (or public wrappers to the methods)??? Thanks

    Read the article

  • Custom array class with assotiated objects

    - by FancyDancy
    I have a simple structure, it's just an array of model's objects. For example, it's a users with books. @books = Book.find(:all, :include = :users) I need to check, does user have a book? I have written a helper method: def has_book?(user_id) @books.select{|b| b.user_id == user_id}.any? end Then, i need to get only books from selected library def in_library(n) @books.select{|b| b.library == n} end I have tried to make custom Array class: class BooksList < Array def initialize(books) self << books end # its my custom methods def has_book?(user_id) self.select{|b| b.user_id == user_id}.any? end def in_library(n) self.select{|b| b.library == n} end end It works, but i have only one problem. I can't access Book's assotiated object (user). So i can't write: @books = BookList.new(Book.find(:all, :include => :users)) @books.first.user.id # it says undefined method `user' for #<Array:0x104b43e08>

    Read the article

  • Getting "value is not defined" while inheriting a type

    - by James Black
    I can't see what I am doing wrong, as the files are in the correct order. In this case it is: BaseDAO.fs CreateDatabase.fs They are in the same namespace, but even when I had them in different modules, and opened the module in CreateDatabase the same error. The error is: Error 1 The value or constructor 'execNonQuery' is not defined I am trying to inherit BaseDAO and use a member that will be common to several files, and I don't see why I get the error above. namespace RestaurantServiceDAO open MySql.Data.MySqlClient type BaseDAO() = let connString = @"Server=localhost;Database=mysql;Uid=root;Pwd=$$$$;" let conn = new MySqlConnection(connString) member self.execNonQuery(sqlStr) = conn.Open() let comm = new MySqlCommand(sqlStr, conn, CommandTimeout = 10) comm.ExecuteNonQuery |> ignore comm.Dispose |> ignore The type that does inherit is here, and execNonQuery is not defined. namespace RestaurantServiceDAO open MySql.Data.MySqlClient type CreateDatabase() = inherit BaseDAO() let createRestaurantTable conn = execNonQuery "CREATE TABLE restaurant(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), cur_timestamp TIMESTAMP(8))"

    Read the article

  • Why can't sub-packages see package private classes?

    - by Polaris878
    Okay so, I have this project structure: package A.B class SuperClass (this class is marked package private) package A.B.C class SubClass (inherits from super class) I'd rather not make SuperClass publicly visible... It is really just a utility class for this specific project (A.B). It seems to me that SubClass should be able to see SuperClass, because package A.B.C is a subpackage of A.B... but this is not the case. What would be the best way to resolve this issue? I don't think it makes sense to move everything in A.B.C up to A.B or move A.B down to A.B.C... mainly because there will probably be an A.B.D which inherits from stuff in A.B as well... I'm a bit new to Java, so be nice :D (I'm a C++ and .NET guy)

    Read the article

  • How to design this class hierarchy?

    - by devoured elysium
    I have defined an Event class: Event and all the following classes inherit from Event: AEvent BEvent CEvent DEvent Now, with the info I gather from all these Event classes, I will make a chart. With AEvent and BEvent, I will generate points for that chart, while with CEvent and DEvent I will paint certain regions of the chart. Now, how should I signal this in my class hierarchy? Should I make AEvent and BEvent inherit from PointEvent while CEvent and DEvent inherit from RegionEvent, being that both RegionEvent and PointEvent inherit from Event? Should I add a field with an Enum to Event with 2 values, Point and Region, and each of the child classes set their value to it? Should I use some kind of pattern here? Which one? Thanks.

    Read the article

  • C++ LNK2019 error with constructors and destructors in derived classes

    - by BLH
    I have two classes, one inherited from the other. When I compile, I get the following errors: 1Entity.obj : error LNK2019: unresolved external symbol "public: __thiscall Utility::Parsables::Base::Base(void)" (??0Base@Parsables@Utility@@QAE@XZ) referenced in function "public: __thiscall Utility::Parsables::Entity::Entity(void)" (??0Entity@Parsables@Utility@@QAE@XZ) 1Entity.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall Utility::Parsables::Base::~Base(void)" (??1Base@Parsables@Utility@@UAE@XZ) referenced in function "public: virtual __thiscall Utility::Parsables::Entity::~Entity(void)" (??1Entity@Parsables@Utility@@UAE@XZ) 1D:\Programming\Projects\Caffeine\Debug\Caffeine.exe : fatal error LNK1120: 2 unresolved externals I really can't figure out what's going on.. can anyone see what I'm doing wrong? I'm using Visual C++ Express 2008. Here are the files.. "include/Utility/Parsables/Base.hpp" #ifndef CAFFEINE_UTILITY_PARSABLES_BASE_HPP #define CAFFEINE_UTILITY_PARSABLES_BASE_HPP namespace Utility { namespace Parsables { class Base { public: Base( void ); virtual ~Base( void ); }; } } #endif //CAFFEINE_UTILITY_PARSABLES_BASE_HPP "src/Utility/Parsables/Base.cpp" #include "Utility/Parsables/Base.hpp" namespace Utility { namespace Parsables { Base::Base( void ) { } Base::~Base( void ) { } } } "include/Utility/Parsables/Entity.hpp" #ifndef CAFFEINE_UTILITY_PARSABLES_ENTITY_HPP #define CAFFEINE_UTILITY_PARSABLES_ENTITY_HPP #include "Utility/Parsables/Base.hpp" namespace Utility { namespace Parsables { class Entity : public Base { public: Entity( void ); virtual ~Entity( void ); }; } } #endif //CAFFEINE_UTILITY_PARSABLES_ENTITY_HPP "src/Utility/Parsables/Entity.cpp" #include "Utility/Parsables/Entity.hpp" namespace Utility { namespace Parsables { Entity::Entity( void ) { } Entity::~Entity( void ) { } } }

    Read the article

  • Java: why does extending need an empty constructor?

    - by HH
    I have classes SearchToUser and getFilesToWord. GetFilesToWord must inherit SearchToUser fields. Extending works if an empty construction in SearchToUser-class, otherwise: cannot find symbol symbol : constructor SearchToUser() location: class SearchToUser public class GetFilesToWord extends SearchToUser{ ^ 1 error make: *** [all] Error 1 I cannot understand why the empty constructor is required for extending.

    Read the article

  • What's the difference between isPrototypeOf and intanceof in Javascript?

    - by Steffen Heil
    Hi In some of my own older code, I use the following: Object.prototype.instanceOf = function( iface ) { return iface.prototype.isPrototypeOf( this ); }; Then I do (for example) [].instanceOf( Array ) This works, but it seems the following would do the same: [] instanceof Array Now, surly this is only a very simple example. My question therefor is: Is a instanceof b ALWAYS the same as b.prototype.isPrototypeOf(a) ? Regards, Steffen

    Read the article

  • Inherit from Type class of .Net

    - by Miguel Angelo
    Is there any point at all on inheriting from Type class in .Net? i.e. What could be the meaning of doing so? I am asking this because of this text in MSDN documentation: Notes to Inheritors When you inherit from Type, you must override the following members... list of members. MSDN doc for Type: http://msdn.microsoft.com/en-us/library/system.type.aspx ok, that is actually saying that anyone can inherit from Type... but they dont say why would you ever want to do that. Thanks!

    Read the article

  • Inheriting from the web client class

    - by robUK
    Hello, C# 2008 I am not sure how much work there is to inheriting from the web client class. Currently I am using it in my project. And I can't change to anything else. The customer would like to have a timeout after a certain period of time. The web client doesn't have this. So rather than re-invent the wheel, I am thinking of inheriting from the web client and adding this property. Do you think this is a suitable solution? Could it mean more work just to add this. What is the easiest way to go about this? Many thanks,

    Read the article

  • How to have a policy class implement a virtual function?

    - by dehmann
    I'm trying to design a policy-based class, where a certain interface is implemented by the policy itself, so the class derives from the policy, which itself is a template (I got this kind of thinking from Alexandrescu's book): #include <iostream> #include <vector> class TestInterface { public: virtual void test() = 0; }; class TestImpl1 { public: void test() {std::cerr << "Impl1" << std::endl;} }; template<class TestPolicy> class Foo : public TestInterface, TestPolicy { }; Then, in the main() function, I call test() on (potentially) various different objects that all implement the same interface: int main() { std::vector<TestInterface*> foos; foos.push_back(new Foo<TestImpl1>()); foos[0]->test(); delete foos[0]; return 0; } It doesn't compile, though, because the following virtual functions are pure within ‘Foo<TestImpl1>’: virtual void TestInterface::test() I thought TestInterface::test() is implemented because we derive from TestImpl1?

    Read the article

  • wcf class implementing two operation contracts in different service contracts with same name

    - by Archie
    Hello, I have declared two service contracts as follows: [ServiceContract] public interface IContract1 { [OperationContract] double Add(int ip); } [ServiceContract] public interface IContract2 { [OperationContract] double Add(double ip); } I have a class which implements these two contracts. I have created two end points for both the contracts. But I'm not able to access the service from client code. It displays a big error when i try to update the service reference as: Metadata contains an error that cannot be resolved.... There was no endpoint listening at ... etc. I know that you can't have two OperationContracts with the same name but is it possible to have two operation contracts in different service contracts with same name but different signature? Thanks.

    Read the article

  • Implementation question involving implementing an interface

    - by Vivin Paliath
    I'm writing a set of collection classes for different types of Trees. I'm doing this as a learning exercise and I'm also hoping it turns out to be something useful. I really want to do this the right way and so I've been reading Effective Java and I've also been looking at the way Joshua Bloch implemented the collection classes by looking at the source. I seem to have a fair idea of what is being done, but I still have a few things to sort out. I have a Node<T> interface and an AbstractNode<T> class that implements the Node interface. I then created a GenericNode<T> (a node that can have 0 to n children, and that is part of an n-ary tree) class that extends AbstractNode<T> and implements Node<T>. This part was easy. Next, I created a Tree<T> interface and an AbstractTree<T> class that implements the Tree<T> interface. After that, I started writing a GenericTree<T> class that extends AbstractTree<T> and implements Tree<T>. This is where I started having problems. As far as the design is concerned, a GenericTree<T> can only consist of nodes of type GenericTreeNode<T>. This includes the root. In my Tree<T> interface I have: public interface Tree<T> { void setRoot(Node<T> root); Node<T> getRoot(); List<Node<T>> postOrder(); ... rest omitted ... } And, AbstractTree<T> implements this interface: public abstract class AbstractTree<T> implements Tree<T> { protected Node<T> root; protected AbstractTree() { } protected AbstractTree(Node<T> root) { this.root = root; } public void setRoot(Node<T> root) { this.root = root; } public Node<T> getRoot() { return this.root; } ... rest omitted ... } In GenericTree<T>, I can have: public GenericTree(Node<T> root) { super(root); } But what this means is that you can create a generic tree using any subtype of Node<T>. You can also set the root of a tree to any subtype of Node<T>. I want to be able to restrict the type of the node to the type of the tree that it can represent. To fix this, I can do this: public GenericTree(GenericNode<T> root) { super(root); } However, setRoot still accepts a parameter of type Node<T>. Which means a user can still create a tree with the wrong type of root node. How do I enforce this constraint? The only way I can think of doing is either: Do an instanceof which limits the check to runtime. I'm not a huge fan of this. Remove setRoot from the interface and have the base class implement this method. This means that it is not part of the contract and anyone who wants to make a new type of tree needs to remember to implement this method. Is there a better way? The second question I have concerns the return type of postOrder which is List<Node<T>>. This means that if a user is operating on a GenericTree<T> object and calls postOrder, he or she receives a list that consists of Node<T> objects. This means when iterating through (using a foreach construct) they would have perform an explicit cast to GenericNode<T> if they want to use methods that are only defined in that class. I don't like having to place this burden on the user. What are my options in this case? I can only think of removing the method from the interface and have the subclass implement this method making sure that it returns a list of appropriate subtype of Node<T>. However, this once again removes it from the contract and it's anyone who wants to create a new type of tree has to remember to implement this method. Is there a better way?

    Read the article

  • PHP syntax for referencing self with late static binding

    - by Chris
    When I learned PHP it was pretty much in procedural form, more recently I've been trying to adapt to the OOP way of doing things. Hoever the tutorials I've been following were produced before PHP 5.3 when late static binding was introduced. What I want to know is how do I reference self when calling a function from a parent class. For example these two methods were written for a User class which is a child of DatabaseObject. Right now they're sitting inside the User class, but, as they're used in other child classes of DatabaseObject I'd like to promote them to be included inside DatabaseObject. public static function find_all() { global $database; $result_set = self::find_by_sql("select * from ".self::$table_name); return $result_set; } and: protected function cleaned_attributes() { global $database; $clean_attributes = array(); foreach($this->attributes() as $key => $value) { $clean_attributes[$key] = $database->escape_value($value); } return $clean_attributes; } So I have three questions: 1) How do I change the self:: reference when I move it to the parent. Is it static:: or something similar? 2) When calling the function from my code do I call it in the same way, as a function of the child class eg User::find_all() or is there a change there also? 3) Is there anything else I need to know before I start chopping bits up?

    Read the article

  • Call the cast operator of template base class within the derived class

    - by yoni
    I have a template class, called Cell, here the definition: template <class T> class OneCell { ..... } I have a cast operator from Cell to T, here virtual operator const T() const { ..... } Now i have derived class, called DCell, here template <class T> class DCell : public Cell<T> { ..... } I need to override the Cell's cast operator (insert a little if), but after I need to call the Cell's cast operator. In other methods it's should be something like virtual operator const T() const { if (...) { return Cell<T>::operator const T; } else throw ... } but i got a compiler error error: argument of type 'const int (Cell::)()const' does not match 'const int' What can I do? Thank you, and sorry about my poor English.

    Read the article

  • c# inheriting generic collection and serialization...

    - by Stecy
    Hi, The setup: class Item { private int _value; public Item() { _value = 0; } public int Value { get { return _value; } set { _value = value; } } } class ItemCollection : Collection<Item> { private string _name; public ItemCollection() { _name = string.Empty; } public string Name { get {return _name;} set {_name = value;} } } Now, trying to serialize using the following code fragment: ItemCollection items = new ItemCollection(); ... XmlSerializer serializer = new XmlSerializer(typeof(ItemCollection)); using (FileStream f = File.Create(fileName)) serializer.Serialize(f, items); Upon looking at the resulting XML I see that the ItemCollection.Name value is not there! I think what may be happening is that the serializer sees the ItemCollection type as a simple Collection thus ignoring any other added properties... Is there anyone having encountered such a problem and found a solution? Regards, Stécy

    Read the article

< Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >