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.
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...
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
{...
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;
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...
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?
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 {...
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 -...
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...
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...
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...
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)...
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...
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...
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...
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...
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();
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...
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...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.