|
peropata wrote: I would also like to be able to open any number of ChildForms and change properties for each individual ChildForm object (so each could display graph with different settings ) ...
just put the this.Owner == toYourMDIParent for each of the child.
peropata wrote: Now I want to add a setup form (shown when pressing button on ChildForm), from which I could change properties of my myGrid object from myGraphGridClass.
There are many options:
One would be to Create a Custom/User Control that encapsuletes your graph form and in that control put the comboboxes textboxes, etc to alter/modify different properties of the graph
Or if you want a setup/properties button create a new form that deals with the different properties
and in the ctor pass in your graph
eg:
SetupForm sf = new SetupForm(this.myGraph)
or something like this.
|
|
|
|
|
Or if you want a setup/properties button create a new form that deals with the different properties
and in the ctor pass in your graph:
SetupForm sf = new SetupForm(this.myGraph)
This code would work for setting properties defined in myDivisionClass class, and not for properties defined in myGraphGridClass . In this case I would have to transfer values from myDivisionClass object to myGraphGridClass object which is created in myDivisionClass . I want ro know if there is a way to directly change properties defined in myGraphGridClass .
Pata
|
|
|
|
|
I don't know much the inner works of myDivisionClass or myGraphGridClass .
But one way would be to pass the myGraphGridClass too in the ctor. It's an object
so you pass the reference to it. And by modifyng the myGraphGridClass in your SetupForm,
you are actually modifyng the one in your child window(s).
All you need to do is call the Invalidate() or refresh method on the grid or the child form, once you
close the setupForm. Or directly from the setup form. The possibilities are countless and you know
better what you want.
|
|
|
|
|
I found the problem. It was my mistake in creating objects. I was creating object MyGraphGridClass inside one of the method of MyDivisionClass and as such it was destroyed as soon as it left that method and its properties could not be accessed. I rearranged a code and put the declaration (creation) of my object as one of the properties of my MyDivisionClass , so I can access its properties.
class MyGraphGridClass
{
private int myProperty;
public int Property
{
get { return myProperty; }
set { myProperty = value; }
}
.
.
.
}
class MyDivisionClass
{
private MyGraphGridClass objMyGraphGrid = new MyGraphGridClass();
internal MyGraphGridClass MyGraphGrid
{
get { return objMyGraphGrid; }
set { objMyGraphGrid = value; }
}
.
.
.
}
MyDivisionClass Graph_01 = new MyDivisionClass();
MyDivisionClass Graph_02 = new MyDivisionClass();
Graph_01.MyGraphGrid.Property = 5;
Graph_02.MyGraphGrid.Property = 3;
SetupForm sf = new SetupForm(Graph_01.MyGraphGrid);
Pata
|
|
|
|
|
Hello,
Being a newbie, I am still coming to grips with understanding C#. I can use a dataset to create a datagrid etc. and I can programatically connect to a database but what gets me is how would you change the database path and have that reflected in you datasets etc.? Perhaps I am not thinking correctly but what I am looking to achieve is to allow and Admin to change the database path (access backend) should this be necessary and have that propogate so that the dataset and adapter will never err due to an incorrect path.
Thanks for your patience,
Art
|
|
|
|
|
Use like a xml/config file where you store the ConnectionSring.
Without the pass if any.
And create a Utlity method that gets the connection from the config file.
|
|
|
|
|
|
Read some documentation(s)!!!
I would use the XLinq to read data.
OK
public static string GetConnection(){
try{
System.Xml.Linq.XDocument doc = System.Xml.Linq.XDocument.Load("confix.xml");
return doc.Element("Connection").Value;
}
catch{
return "failure";
}
}
<?xml version="1.0" encoding="utf-8" ?>
<Connection>"MyConnectionWithoutPassHere"</Connection>
|
|
|
|
|
Hi,
I have a Windows application, written in c# and in my application, I have a DataGridView that has 2 DataGridViewComboBoxColumns in it, along with a DataGridViewTextBoxColumn. The 2 ComboBoxColumns are each populated by a DataSet. For each row, the user selects an item from each of the ComboBoxColumns and enters a number into the TextBoxColumn. As an example, let's say the Color ComboBox has 3 choices in it: Red, Blue & Green and the Size ComboBox has 3 choices in it: Small, Medium & Large. In our example, for the first row, the user has selected Red from the Color ComboBox, Medium for the Size ComboBox and has entered "5" in the Qty TextBox. For Row 2, the user selected Green in that Color ComboBox, Large in the Size ComboBox and has entered "4" in the Qty TextBox.
Row...........Color(ComboBox).........Size(ComboBox)......Qty(TextBox)
----------------------------------------------------------------------------------
..1............Red...............................Medium......................5
..2............Green...........................Large.........................4
Once the user is done, this information is saved to a table. Let's also assume that this information was for January, 2010.
When the user starts a new month, (February, 2010, for example), their data could be exactly the same as January or it may change a little. If it IS the same or very close to the same, rather than force the user to reenter all of the information as they did in January, I'd like to be able to give them the option to "import" the data from January but still give them all the options that they had in January. What this means is that the Color ComboBoxColumn for each row still has Red, Blue & Green as its items that can be chosen, but for Row1, "Red" needs to be the selected item and for Row 2, "Green" needs to be the selected item. Keeping with that same idea, the Size ComboBox still has Small, Medium and Large as its items that can be selected for each row, but for Row 1, "Medium" needs to be set as the selected item and for Row 2, "Large" needs to be the selected item.
My DataGridView would be populated the exact same way as it did in January but the selected items that show would be the data that the user had chosen in January. Because I'm retrieving that data (what the user chose in Jan) from the database, I know that in the DataGridView cell for Row1, Color ComboBox, the selected item should be "Red". Since I know that, how do I set the selected item in that ComboBox to "Red"? If this was a straight ComboBox, I know how to set the SelectedItem (or SelectedIndex). But because this is a DataGridViewComboBox, it doesn't seem to work the same way.
Any ideas or suggestions will be greatly appreciated. If more information is needed in order to help me solve this, please let me know.
Thanks in advance.
Ron
|
|
|
|
|
Assume there are two classes: Zoo and Animals. Something like this:
public class Zoo{
public int Id;
public string Name;
public List< Animals > animals;
}
public class Animals{
public int Id;
public string Name;
}
Now, I have two generic lists:
1. List of Zoo
2. List of Animals
3. Any kind of collection (I cannot decide which one to use) which will have Zoo.Id and Animal.Id. This collection would be used as a map between Zoo and Animals. Here each Zoo will have multiple animals and same animal can be a part of multiple zoos.
I need to get the list of Animals in a Zoo and then set that value to Zoo.animals list. I am thinking to use LINQ. Something like:
foreach(Zoo zoo in zooList){
zoo.animals = (from animal in animalList
where collectionThree[animal.Id] = zoo.Id
select animal).ToList();
}
But since collectionThree cannot be a Dictionary/HashTable, this wont work. Any ideas how to do this?modified on Wednesday, March 10, 2010 10:56 PM
|
|
|
|
|
Union statement in SQL Server can be useful.
|
|
|
|
|
Or SortedList. Ex:
public SortedList<Animal, Zoo> map = new SortedList<Animal, Zoo>();
...
...
...
zoo.animals = (from animal in animalList
where map[animal].Id == zoo.Id
select animal).ToList();
}
or
public SortedList<int, int> map = new SortedList<int, int>();
...
...
...
zoo.animals = (from animal in animalList
where map[animal.Id] == zoo.Id
select animal).ToList(); modified on Wednesday, March 10, 2010 2:25 PM
|
|
|
|
|
Thanks!
SortedList is what I was looking for.
|
|
|
|
|
Your 3rd collection is necessary, in fact it breaks the object encapsulation IMO.
What you really need is a List<Zoo> property on Animal , and conversely a List<Animal> property on Zoo . All you need do is ensure that the lists are not accessible publicly, and methods are provided for addition / removal to both list properties "simultaneously" (i.e. adding an Animal to a zoo also adds that zoo to an animal). You will also need properties or methods for getting copies (so the originals are unalterable externally) of the lists.Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
Or make them totally unaware of each other as in:
class Animal{
public int Id{get;set;}
public string Name{get;set;}
}
class Zoo{
public int Id{get;set;}
public string Name{get;set;}
}
SortedList<int,int> animalZooJonction = new SortedList<int, int>();
var animalsInSpecifiedZoo = (from rec in animals
where animalZooJonction[rec.Id] == zoo
select rec).ToList();
While it is not as keen on respecting standars it is faster and it does consume less memory.
|
|
|
|
|
Thanks for the reply.
I have tried to make actual scenario simpler with that example. The actual code is a bit different. What you have said is there in the actual code as well except for having lists in both the classes.
|
|
|
|
|
I need to run an installer action under the current user context, while it is runned under System user's context.
How it is possible?
|
|
|
|
|
|
0) PDFWriter there only supplies an emulated printer in your printer list that will create your PDFs for you so doesn't have any programmatic interface for you to use.
1) You need to instead go for their SDK here: http://www.cutepdf.com/Solutions/FormSDK.asp[^]
2) If you hit snags with that, I suggest you use cutepdf's support options. CP is more about generic programming techniques, not software specific ones that belong to people unaffiliated with it.
|
|
|
|
|
Hi All!
I’ve made a class that inherits from ComboBox and have added MinDate, MaxDate, and Value properties. In the constructor of the class I set the default values I want for those properties (they can be overridden by setting the property).
I used the VS 2005 designer to place my custom ComboBoxes on my form, but the designer keeps assigning default values for MinDate, MaxDate, and Value which are overriding the defaults I set in the constructor. When I try and remove the designer code that just deals with the assignment of those three properties the designer adds them back in after the next edit.
Is there a way to still use the designer but not have it hijack my custom controls?
Thank you all in advance!
|
|
|
|
|
On your properties you need to have the DefaultValue attribute with your defaults in. This will then stop the designer automatically overriding your defaults. This will also give you Reset functionality in the designer.
E.g.
[System.ComponentModel.DefaultValue("My Default value")]
public string MyProperty{
set{
}
}
|
|
|
|
|
Thank you for the reply. This looks like what I’m looking for. However, the complier won’t let me set the DefaultValue to DateTime.Now (or any other DateTime object) and I’ve had no luck finding an answer on the net.
The complier complains with the error “An attribute argument must be a constant expression, typeof expression or array creation expression”
It seems like the Designer is setting all of these values because it wants to be able to display how my control would actually look when run, but I don’t care about that at design time, I’m just using the designer to line up my controls.
Is there a way to stop the designer from trying to “figure out” what my control would look like and just set its placement?
Thanks again!
|
|
|
|
|
Anticast wrote: However, the complier won’t let me set the DefaultValue to DateTime.Now (or any other DateTime object) and I’ve had no luck finding an answer on the net.
In orther to use it as default value, use this: [DefaultValue(typeof(DateTime), "Now")]
NOTE: When using atribute DefaultValue, you must also set the default value to the code. this attribute only tells to your IDE. And IDE (VS08 or others) removes property from auto generated code. DateTime changes and it is impossible to use it as default value without Type converzion. Introduction to the TypeConverter
Anticast wrote: Is there a way to stop the designer from trying to “figure out” what my control would look like and just set its placement?
I do not understand you with this. Are you looking into this.DesignMode property in order to change behaviour?. Designer can't try to figure out your controls look. Every time you compile IDE uses its compiled info and then it displays on designer by using latest build
|
|
|
|
|
If you don't want the designer to serialize your properties, add a System.ComponentModel.DesignerSerializationVisibilityAttribute set to NeverDave
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Awesome! This did exactly what I was looking for. Thank you!
For anyone else that is using ComboBoxes (or similar controls, I'm sure) I also had to add:
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
new public ComboBox.ObjectCollection Items
{
get
{
return base.Items;
}
}
to get the Designer to stop adding items to my collection. Without this the constructor was adding its items, then the designer added those items again.
Thanks again!
|
|
|
|