Search Results

Search found 9771 results on 391 pages for 'equivalence classes'.

Page 61/391 | < Previous Page | 57 58 59 60 61 62 63 64 65 66 67 68  | Next Page >

  • C#: Need one of my classes to trigger an event in another class to update a text box

    - by Matt
    Total n00b to C# and events although I have been programming for a while. I have a class containing a text box. This class creates an instance of a communication manager class that is receiving frames from the Serial Port. I have this all working fine. Every time a frame is received and its data extracted, I want a method to run in my class with the text box in order to append this frame data to the text box. So, without posting all of my code I have my form class... public partial class Form1 : Form { CommManager comm; public Form1() { InitializeComponent(); comm = new CommManager(); } private void updateTextBox() { //get new values and update textbox } . . . and I have my CommManager class class CommManager { //here we manage the comms, recieve the data and parse the frame } SO... essentially, when I parse that frame, I need the updateTextBox method from the form class to run. I'm guessing this is possible with events but I can't seem to get it to work. I tried adding an event handler in the form class after creating the instance of CommManager as below... comm = new CommManager(); comm.framePopulated += new EventHandler(updateTextBox); ...but I must be doing this wrong as the compiler doesn't like it... Any ideas?!

    Read the article

  • Modules vs. Classes and their influence on descendants of ActiveRecord::Base

    - by Chris
    Here's a Ruby OO head scratcher for ya, brought about by this Rails scenario: class Product < ActiveRecord::Base has_many(:prices) # define private helper methods end module PrintProduct attr_accessor(:isbn) # override methods in ActiveRecord::Base end class Book < Product include PrintProduct end Product is the base class of all products. Books are kept in the products table via STI. The PrintProduct module brings some common behavior and state to descendants of Product. Book is used inside fields_for blocks in views. This works for me, but I found some odd behavior: After form submission, inside my controller, if I call a method on a book that is defined in PrintProduct, and that method calls a helper method defined in Product, which in turn calls the prices method defined by has_many, I'll get an error complaining that Book#prices is not found. Why is that? Book is a direct descendant of Product! More interesting is the following.. As I developed this hierarchy PrintProduct started to become more of an abstract ActiveRecord::Base, so I thought it prudent to redefine everything as such: class Product < ActiveRecord::Base end class PrintProduct < Product end class Book < PrintProduct end All method definitions, etc. are the same. In this case, however, my web form won't load because the attributes defined by attr_accessor (which are "virtual attributes" referenced by the form but not persisted in the DB) aren't found. I'll get an error saying that there is no method Book#isbn. Why is that?? I can't see a reason why the attr_accessor attributes are not found inside my form's fields_for block when PrintProduct is a class, but they are found when PrintProduct is a Module. Any insight would be appreciated. I'm dying to know why these errors are occurring!

    Read the article

  • Where does the compiler store methods for C++ classes?

    - by Mashmagar
    This is more a curiosity than anything else... Suppose I have a C++ class Kitty as follows: class Kitty { void Meow() { //Do stuff } } Does the compiler place the code for Meow() in every instance of Kitty? Obviously repeating the same code everywhere requires more memory. But on the other hand, branching to a relative location in nearby memory requires fewer assembly instructions than branching to an absolute location in memory on modern processors, so this is potentially faster. I suppose this is an implementation detail, so different compilers may perform differently. Keep in mind, I'm not considering static or virtual methods here.

    Read the article

  • How do I make Pseudo classes work with Internet Explorer 7/8?

    - by Mel
    I've written the following code to create a three-column layout where the first and last columns have no left and right margins respectively: #content { background-color:#edeff4; margin:0 auto 30px auto; padding:0 30px 30px 30px; width:900px; } .column { float:left; margin:0 20px; } #content .column:nth-child(1) { margin-left:0; } #content .column:nth-child(3) { margin-right:0; } The problem is that this code does not work in Internet Explorer 7 and 8? The only pseudo class I can use with IE (in this case) would be "first-child," but this does not eliminate the right margin on the third and last column. Does anyone know of a way I can make this code work on IE 7/8?

    Read the article

  • [C#] How to share a variable between two classes?

    - by Altefquatre
    Hello, How would you share the same object between two other objects? For instance, I'd like something in that flavor: class A { private string foo_; // It could be any other class/struct too (Vector3, Matrix...) public A (string shared) { this.foo_ = shared; } public void Bar() { this.foo_ = "changed"; } } ... // inside main string str = "test"; A a = new A(str); Console.WriteLine(str); // "test" a.Bar(); Console.WriteLine(str); // I get "test" instead of "changed"... :( I read there is some ref/out stuff, but I couldn't get what I'm asking here. I could only apply some changes in the methods scope where I was using ref/out arguments... I also read we could use pointers, but is there no other way to do it? Thanks Altefquatre

    Read the article

  • Why has Foundation 4 made its grid classes less natural and readable?

    - by Brenden
    The Background I love responsive CSS grids. I hate Bootstrap's complex class names. I fell in love with Foundations human readable class names. The Problem With Foundation 4, they have changed four columns to large-4 small-4 columns and in my opinion this makes the HTML markup less clear. This style of CSS class names is exactly why I switched from Bootstrap to Foundation. The Question What advantage is gained by Foundation 4's Grid in making this change? It seems that you can have a different grid layout on smaller screens via media queries, but I can't think of a design that would require this. Note: I've been focused on native mobile development and therefore I may be missing out on recent best practices.

    Read the article

  • How to: Display multiple related classes in an ASP.NET GridView ?

    - by kversch
    I would like to display students and their grades with a GridView and LinqToSQL like this: assignment1 assignment2 Student 1 55 89 Student 2 87 56 Student 3 92 34 I found this topic but it doesn't answer my question: http://forums.asp.net/t/1557987.aspx I have a many-to-many relationship between students and assignments called "grades". The grade for the assignment is stored in that table in a "gradeNumber" column. I would also like to specify which assignments should be displayed in the grid. Btw, my LINQ entities are extended to allow me to write/get studentx.Assignments or assignmentx.Students.

    Read the article

  • The same property and procedure in different Classes. How they can be accessed ?

    - by lyborko
    Hi, I created several new objects TMyMemo = class (TMemo) private FYahoo = Integer; procedure SetYahoo(Value:integer) public procedure Google(A,B:integer; S:string); published property Yahoo:integer read FYahoo write SetYahoo; end; TMyPaintbox = class (TPaintbox) private FYahoo = Integer; procedure SetYahoo(Value:integer) public procedure Google(A,B:integer; S:string); published property Yahoo:integer read FYahoo write SetYahoo; end; TMyButton = class (TButton) private FYahoo = Integer; procedure SetYahoo(Value:integer) public procedure Google(A,B:integer; S:string); published property Yahoo:integer read FYahoo write SetYahoo; end; . . . These Controls are placed on Form1. Is there a way, how can I change the same property (Yahoo) and run the procedure (Google), which is declared in different objects (inheritance is not possible) ? procedure Form1.Button1Click(Sender:TObject); var i:integer; begin for i:=0 to Form1.ControlCount-1 do begin Controls[i].Google(4,5, 'Web'); // this should be changed somehow Controls[i].Yahoo:=6; // this should be changed somehow end; end; end; Thanks

    Read the article

  • How to mimic polymorphism in classes with template methods (c++)?

    - by davide
    in the problem i am facing i need something which works more or less like a polymorphic class, but which would allow for virtual template methods. the point is, i would like to create an array of subproblems, each one being solved by a different technique implemented in a different class, but holding the same interface, then pass a set of parameters (which are functions/functors - this is where templates jump up) to all the subproblems and get back a solution. if the parameters would be, e.g., ints, this would be something like: struct subproblem { ... virtual void solve (double& solution, double parameter)=0; } struct subproblem0: public subproblem { ... virtual void solve (double& solution, double parameter){...}; } struct subproblem1: public subproblem { ... virtual void solve (double* solution, double parameter){...}; } int main{ subproblem problem[2]; subproblem[0] = new subproblem0(); subproblem[1] = new subproblem1(); double argument0(0), argument1(1), sol0[2], sol1[2]; for(unsigned int i(0);i<2;++i) { problem[i]->solve( &(sol0[i]) , argument0); problem[i]->solve( &(sol1[i]) , argument1); } return 0; } but the problem is, i need the arguments to be something like Arg<T1,T2> argument0(f1,f2) and thus the solve method to be something of the likes of template<T1,T2> solve (double* solution, Arg<T1,T2> parameter) which cant obviously be declared virtual ( so cant be called from a pointer to the base class)... now i'm pretty stuck and don't know how to procede...

    Read the article

  • Why are changes to classes ignored after dom changes?

    - by Lg102
    I have a price grid that uses relative positioning to move a field around, beneath a box with: overflow: hidden;. In this is field, there are absolute-positioned boxes containing prices. When this box is hovered, the matching values above and left of the will change color. In order to achieve this, a class is toggled using jQuery. This initially works. However, after the grid is moved, the class change doesn't affect the block above the grid anymore. In the Chrome console, i can see the class being added, but it's css-styling isn't applied. No other styles for the element have changed. I am 100% sure there is no other style-rule influencing the element, it just stops responding to the change in class after the DOM has been altered. Can i 'refresh' the DOM somehow? Edit: I've tried to get the relevant code only: Adding the cell in the first place: $("#price_dates_cells").append("<div id='"+weekday[theBeginDate.getDay()]+"-"+theBeginDate.getDate()+"-"+(theBeginDate.getMonth()-1)+"' class='datecell' style='left: "+( Math.floor( difference / ( 3600 * 24 * 1000) ) * ( cellwidth ) )+"px'>"+weekday[theBeginDate.getDay()]+"<br>"+theBeginDate.getDate()+" "+yearmonth[theBeginDate.getMonth()]+"</div>"); Toggle the class: var str_element = "#"+weekday[Bdate.getDay()]+"-"+Bdate.getDate()+"-"+(Bdate.getMonth()-1); $(str_element).toggleClass("red"); and the movement that seems to cause the problem: $('#price_grid').animate({"top": (( ( horizontalMovement ) * cellheight)) }, 'fast', 'linear');

    Read the article

  • Android layouts within layouts, with separate classes handling their input?

    - by Demonofloom
    Hey all, I have created a program in Java that uses Jpanels within Jpanels. One example of this is having a side view containing buttons that change the main view when pressed. The main view also has buttons that can be used to alter itself. I am trying to re-create this on the android. I have my layout set up from an xml, with a side panel containing buttons and the main view. There is another xml that contains what I want in the main view. Now I am struggling to get this separate xml to be displayed in the main view and can’t figure out how I would get the class to handle its own input. I don’t want to paste the code into the main.xml as I want to keep things object orientated and each view needs some custom elements such as different textviews. An example of what I am trying to convert for the android is below:- //The ViewInt class has its own layout ViewInt tempView = new ViewInt(i, mFloorNo); //The viewInt class is then added to the main window. mainWindowPanel.add(tempView); This small bit of code would create a view, add it to the main view and then any input in the main window is handled by that class, but at the same time any input not in this main window is handled by another class (probably the root class). Any help is greatly appreciated, thanks. To clarify: The program has a side panel layout, containing buttons. And a main view layout that is empty. I am trying to set a .xml layout to this main view layout, and have it so that if any buttons are pressed in that main view then a class for that layout will handle it.

    Read the article

  • Passing arguments between classes - use public properties or pass a properties class as argument?

    - by devoured elysium
    So let's assume I have a class named ABC that will have a list of Point objects. I need to make some drawing logic with them. Each one of those Point objects will have a Draw() method that will be called by the ABC class. The Draw() method code will need info from ABC class. I can only see two ways to make them have this info: Having Abc class make public some properties that would allow draw() to make its decisions. Having Abc class pass to draw() a class full of properties. The properties in both cases would be the same, my question is what is preferred in this case. Maybe the second approach is more flexible? Maybe not? I don't see here a clear winner, but that sure has more to do with my inexperience than any other thing. If there are other good approaches, feel free to share them. Here are both cases: class Abc1 { public property a; public property b; public property c; ... public property z; public void method1(); ... public void methodn(); } and here is approach 2: class Abc2 { //here we make take down all properties public void method1(); ... public void methodn(); } class Abc2MethodArgs { //and we put them here. this class will be passed as argument to //Point's draw() method! public property a; public property b; public property c; ... public property z; } Also, if there are any "formal" names for these two approaches, I'd like to know them so I can better choose the tags/thread name, so it's more useful for searching purposes. That or feel free to edit them.

    Read the article

  • How to use templated classes as function arguments? (C++)

    - by Keand64
    I have a class declared along the lines of template<int a, int b> class C { public: array[a][b]; } and I want to use it as argument in a function like this: bool DoSomeTests(C &c1, C &c2); but when I compile, it tells me 'use of class template requires template argument list.' I tried template<int a, int b> bool DoSomeTests(C &c1, C &c2); but I get the same error. How can I fix this?

    Read the article

  • Where do you put non-controller classes in codeigniter?

    - by sprugman
    I've got a class Widgets. Widgets are made up of Doohickies. I'm never going to need to access Doohickies directly via url -- they're essentially a private class, only used by Widgets. Where do you put your code to define the Doohicky class? In /app/controllers/doohicky.php? in app/controllers/widget.php? somewhere else? Obviously, the former seems cleaner, but it's not obvious to me how to make the Doohicky class available to Widget.

    Read the article

  • How to implement a private virtual function within derived classes?

    - by Dane
    Hi, I know why I want to use private virtual functions, but how exactly can I implement them? For example: class Base{ [...] private: virtual void func() = 0; [...] } class Derived1: puplic Base{ void func() { //short implementation is ok here } } class Derived2: puplic Base{ void func(); //long implementation elsewhere (in cpp file) } [...] void Derived2::func() { //long implementation } The first version is ok but not always possible. Isn't the second version simply name hiding? How do you define the Base::func() of Derived2, if you cannot do it within the class declaration of Dereived2? Thanks

    Read the article

< Previous Page | 57 58 59 60 61 62 63 64 65 66 67 68  | Next Page >