Search results for query: *

  • Users: bondra
  • Content: Threads
  • Order by date
  1. B

    Set a string value for boolean True/False

    Is it possible to output a boolean value True/False to say Yes/No instead?
  2. B

    Answered Adding different buttons to rows datagridview

    Is it possible to have custom buttons on different rows using Datagridview? I manage to have each button in two separate columns. But not in the same one. How can this be done? I can post the current code I'm using if needed.
  3. B

    Answered Get object sent with event

    I have a button column in a datagrid. The datagrid is printing out a list of animals. When clicking the button column I would like to get the corresponding animal object. I found some interesting data that's being sent but this is as a string like: Doggy, Bone, Large, Button. What I'm looking...
  4. B

    Resolved Get data from multiple sources?

    I'm trying to get data from two lists/sources to populate my datagrid view. I manage to print all fields for an animal but the list of Toys. How can I proceed with this one? What's the correct route? This is what my code looks like: Petowner.Pets.Add(new Cat {...
  5. B

    Answered Reach dataGridView within a user controller?

    I'm trying to reach dataGridView1 which is in a user controller. Syntax below is wrong.... any ideas what the correct one is? :) userControlListAnimals1.dataGridView1.DataSource = Pets;
  6. B

    DefaultCellStyle Forecolor only applies to one cell

    I'm trying to set a color for the DefaulyCellStyle property but in only color the first cell for some reason. Any ideas? // Set the selection background color for all the cells. dataGridView1.DefaultCellStyle.SelectionBackColor = Color.White...
  7. B

    Question Added property don't update data source

    I've added an propery in a class which I now trying to reach from my Data Grid View. It doesn't show up however. I've tried to add new Data Sources, removed the DataGridView and added a new one but that doesn't seem to do anything. Any ideas?
  8. B

    Question Your opinion regarding constructor

    If you look at the code below. What would you say is wrong with the Puppy constructor? Is there any obvious between the classes the class Dog and the inherited Puppy? class Puppy : Dog { // Properties public int AgeInMonths { get; set; } override public int Age {...
  9. B

    Question Remove the object invoking a class/method

    Don't know if the title of the post describes what I want and trying to achieve. But I try to explain it below. abstract class Toy { public int Quality { get; set; } = 10; public virtual int LowerQuality(int inputQuality) { int calcQuality = Quality -...
  10. B

    Question Method only run once during object creation

    For some reason which I can't figure out, my static method ShuffleProbability() only runs once during the creation of objects. I was hoping that for each object creation it would go into the ShuffleProbability method and generate either false/true and set the property IsHungry to the returned...
  11. B

    Resolved Cast base object to an inherited object

    I'm trying to cast an object that's being passed into a method to one of its inherited classes/objects. Since I want to prevent duplicated code as far as possible. Last example is the working one and maybe the best solution even though it has duplicated text blocks? What's your thoughts on this...
  12. B

    Question Get type name of inherited class

    What is the best way to go in order to get the class name when creating an object? This is what I've got but need help with syntax as well as what the best practises are. class Animal { public string Name { get; set; } public int Age { get; set; } public string FavFood { get...
  13. B

    Question Get get a type in given context

    This driving me nuts. I can't get reach of Toy and really don't know why... This is what the code looks like stripped down: abstract class Animal { public List<Toy> Toy { get; set; } = new List<Toy>(); } abstract class Toy { } class Petowner { int i = 1; foreach (var toy in Toy)...
  14. B

    Resolved Cannot implicitly convert type 'void' to...

    I just staring och scrolling upp and down with no ideas of how to proceed :mad: I get following "Error CS0029 Cannot implicitly convert type 'void' to 'Joppes_hundar.Toy'". There're a lot of posts of there but none seems to help me. I've left out code. Please let me know if further code...
  15. B

    Pin terminal on dual montitors when debugging

    Is it somehow possible to pin the console window? I've two monitors and each time I debug using the "Step into" the terminal opens above the document . This forces me to move the terminal to my other monitor every time! Really disturbing and time consuming. Edit: I noticed putting the Visual...
  16. B

    Resolved Assigning value to nested array

    I'm having problem with the syntax of how to add an existing value to the index of an array in array. Assigning values to the main array is no problem i.e.: Pets[0].Name = "Brooom"; ... but reaching the Toys array and its fields is a trickier one. I manage to get the field by iterating through...
  17. B

    Question Get fields in inherited class

    I'm trying to set the Length field from the inherited class Bone. But only the fields from the base class Toy appears. Any ideas? Pets[0].Name = "Brooom"; Pets[0].Toys[2].// Fields from inherited class missing // Create dummy animals at start...
  18. B

    Resolved What is Animal in Animal cat = new Cat();

    Simple question, but I'm currently commenting my code and started wondering. Is this correct? // Creates a new instance of the object Cat, inherited from the class Animal Animal cat = new Cat();
  19. B

    Question Feedback on class diagram

    So this is my class diagram. Is there anything that can be improved right away? Some questions: 1. The backing fields, should they be in camelCase or Pascal? 2. The usage of the diamond arrow seen in the picture is tricky. Is there any rule of thumb to remember? Should the diamond go to the...
  20. B

    Question Naming convention with only capitalized letters

    I've gotten following part for an UML-diagram. I don't like the way the method CAT is written however with only capitalized letters. I understand why since it will conflict with the name of the class otherwise. But is there some standard naming convention for this scenario? CAT + Cat (in name...
Back
Top Bottom