|
You're welcome.
PS: even when using doesn't fit the application, don't forget to dispose of long lived DataTables!
|
|
|
|
|
Is it possible to have one XMLDocument for all MDI Children so that I only need to invoke the .save once from MDI container instead of doing it every time in every child?
|
|
|
|
|
|
You sound like you need to consider using the Observer pattern:
With all the children being registered observers, you just need to fire up the save method in the object (MDI form) and it'll take care of saving the other forms.
If the post was helpful, please vote, eh!
Current activities:
Book: Devils by Fyodor Dostoyevsky
Project: Hospital Automation, final stage
Learning: Image analysis, LINQ
Now and forever, defiant to the end.
What is Multiple Sclerosis[ ^]?
|
|
|
|
|
I have a class called save_changes() in evey MDI child... How can I run that class for every open MDI when I click a button on my MDI parent?
|
|
|
|
|
Well, you can loop over the MdiChildren collection and call that save_changes method on each one.
Eslam Afifi
|
|
|
|
|
I have been asking around to see if there is an existing class method in C# to do this and it appears not so I worked out my own methods if anyone is interested or needs them.
double angle = 45.2413;
double degminsec = angle;
double decsec = (degminsec * 100 - Math.Truncate(degminsec*100)) / .6;
double degmin = (Math.Truncate(degminsec * 100) + decsec) / 100;
double deg = Math.Truncate(degmin);
double decdeg = deg + (degmin - deg) / .6;
And this is to go back the other way:
double angle = 45.4036;
double decdeg = angle;
double minsec = (decdeg - Math.Truncate(decdeg)) * 60;
double sec = (minsec - Math.Truncate(minsec)) * 60;
double degminsec = (Math.Truncate(sec) / 10000) + (Math.Truncate(minsec) / 100) + Math.Truncate(decdeg);
|
|
|
|
|
Posting this as a tip would perhaps be better than in a forum.
|
|
|
|
|
Ok thanks. I'm new to here so not sure how to do that.
|
|
|
|
|
You will find it under articles menu on the top Post Tip & Trick[^]
Tarakeshwar Reddy
There are two kinds of people, those who do the work and those who take the credit. Try to be in the first group; there is less competition there. - Indira Gandhi
|
|
|
|
|
The only problem with these conversions is that you will get incorrect answers. Try running a few tests to see what happens when converting between decimal values and floating point.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
How about just doing something like
deg + min / 60 + sec / 3600
Tarakeshwar Reddy
There are two kinds of people, those who do the work and those who take the credit. Try to be in the first group; there is less competition there. - Indira Gandhi
modified on Saturday, March 27, 2010 3:49 PM
|
|
|
|
|
That would be fine except that it is entered in the format
##.####. You would have to use 3 separate input modes otherwise and that isn't practical for surveying.
|
|
|
|
|
Hey all,
I've a dictionary, i sort his keyValuePair set with linq, and now i want to update my dictionary with the sorted set, how can i do that ?
tanks
|
|
|
|
|
I don't think you can update the dictionary.
You must create a new one. Something like this:
Dictionary<int, string> original = new Dictionary<int, string>();
original.Add(2, "absolutely");
original.Add(1, "undoubtely");
var sortedKeys = (from rec in original
orderby rec.Key
select rec.Key).ToList();
Dictionary<int, string> second = new Dictionary<int, string>();
for (int i = 0; i < sortedKeys.Count; i++)
{
second.Add(sortedKeys[i], original[sortedKeys[i]]);
}
[Edit]A different option is to use the SortedDictionary [/Edit]
|
|
|
|
|
A dictionary has a Clear method.
Using this method, the Count property is set to 0, and references to other objects from elements of the collection are also released.
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Yeah but then how will he know wich value/object to insert at a given key?
|
|
|
|
|
and if i wont use the Clear method ?
there is no way to add new keyValuePair set to the dictionary ?
|
|
|
|
|
My bad. I thought you wanted to sort just on the key and select just the key.
Here's a working solution using the Clear() method.
var sortedKeys = (from rec in original
orderby rec.Key ascending, rec.Value ascending
select rec).ToList();
original.Clear();
for (int i = 0; i < sortedKeys.Count;i++ )
{
original.Add(sortedKeys[i].Key, sortedKeys[i].Value);
}
|
|
|
|
|
guess what,
when original.Clear() is executed, all the sorted set is gone...
|
|
|
|
|
Yes and NO.
If you don't use the .ToList() after the Linq then yes.
Else no.
|
|
|
|
|
you right, i forgot the .toList()
tanks...
|
|
|
|
|
Your question does not make sense. A dictionary does not have any defined order.
Yes you can get the pairs out of a dictionary and sort them. But if you insert them in a new/cleared dictionary, there's no guarantee they will keep that order.
The dictionary class is allowed to reorder elements as it sees fit (to make loopup faster). Often the order of insertion is preserved, but it's not guaranteed.
If you need your pairs to stay in sorted order, don't use a dictionary. Either use a List<KeyValuePair<...>>, or (if sorting by key) use a SortedDictionary<...>.
|
|
|
|
|
|
namespace MYConsoleApplication
{
class Program
{
static void Main(string[] args)
{
int x = 3;
int y = 2;
x= (x==y++)?x+y:x-y;
A ObjA = new A();
ObjA.M1();
}
}
interface Inf1
{
void M1();
void M2();
}
interface Inf2
{
void M1();
}
class A: Inf1,Inf2
{
public void M1()
{
Console.Write("test");
}
public void M2()
{
Console.Write("test2");
}
}
}
From the above code ..how can i know from which interface the method M1() is overriding in Class A. Please let me know..if this is the case where tow interfaces contains same method..
G. Satish
|
|
|
|