|
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
|
|
|
|
|
See "Avoiding Name Ambiguity" section of this[^] article.
|
|
|
|
|
It is not overriding M1, it is implementing it for BOTH interfaces. If you wanted, you could also explicitly implement it for each interface (so that casting it as Inf1 and calling M1 will do something different than casting it as Inf2 and calling M1).
|
|
|
|
|
I want to write a use control named Notebook just as TableControl.
When desigining, user draws one user control, Notebook to one form and can use the property of the Notebook to edit the Pages in this Notebook. How do I to write this property design?
I write a class PageEditor inherited from System.Drawing.Design.UITypeEditor,
But I do not know which method needed to override? and what needed to do in the override method?
Can anyone help me?
|
|
|
|
|
<br />
public class Notebook : UserControl<br />
{<br />
#region Notebook<br />
public Notebook() : base()<br />
{<br />
InitializeComponent();<br />
<br />
this.SuspendLayout();<br />
Page newPage = new Page();<br />
newPage.Name = "newPage";<br />
this.Controls.Add(newPage);<br />
newPage.Dock = DockStyle.Fill;<br />
newPage.Visible = true;<br />
this.ResumeLayout(false);<br />
<br />
this.Dock = DockStyle.Fill;<br />
this.BackColor = Color.Yellow;<br />
}<br />
<br />
private System.ComponentModel.IContainer components = null;<br />
<br />
protected override void Dispose(bool disposing)<br />
{<br />
if (disposing && (components != null))<br />
{<br />
components.Dispose();<br />
}<br />
base.Dispose(disposing);<br />
}<br />
<br />
#region 组件设计器生成的代码<br />
<br />
private void InitializeComponent()<br />
{<br />
this.SuspendLayout();<br />
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);<br />
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;<br />
this.Name = "Notebook";<br />
this.Size = new System.Drawing.Size(549, 217);<br />
this.ResumeLayout(false);<br />
<br />
}<br />
#endregion<br />
#endregion<br />
<br />
private int _pageIndex;<br />
[Category("Appearance")]<br />
[Description("当前页面索引号")]<br />
[DefaultValue(0)]<br />
public int PageIndex<br />
{<br />
get { return this._pageIndex; }<br />
set { this._pageIndex = value; }<br />
}<br />
<br />
private String _pages;<br />
[Category("Appearance")]<br />
[Description("所有页面")]<br />
[Editor("PageEditor", typeof(PageEditor))]<br />
public String Pages<br />
{<br />
get { return this._pages; }<br />
set { this._pages = value; }<br />
}<br />
<br />
}<br />
<br />
<br />
public class PageEditor : System.Drawing.Design.UITypeEditor<br />
{<br />
public PageEditor()<br />
: base()<br />
{<br />
<br />
}<br />
<br />
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)<br />
{<br />
return base.EditValue(context, provider, value);<br />
}<br />
}<br />
<br />
<br />
public class Page : System.Windows.Forms.Panel<br />
{<br />
public Page() :base()<br />
{<br />
InitializeComponent();<br />
<br />
<br />
this.BorderStyle = BorderStyle.Fixed3D;<br />
Label label1 = new Label();<br />
label1.Text = "fadfadfaef";<br />
this.Controls.Add(label1);<br />
}<br />
<br />
private System.ComponentModel.IContainer components = null;<br />
<br />
protected override void Dispose(bool disposing)<br />
{<br />
if (disposing && (components != null))<br />
{<br />
components.Dispose();<br />
}<br />
base.Dispose(disposing);<br />
}<br />
<br />
#region 组件设计器生成的代码<br />
<br />
private void InitializeComponent()<br />
{<br />
this.SuspendLayout();<br />
this.Name = "Page";<br />
this.Size = new System.Drawing.Size(553, 277);<br />
this.ResumeLayout(false);<br />
<br />
}<br />
#endregion<br />
}<br />
<br />
<br />
I want to write the Editor of Notebook's property, Pages. How can I make it? :( <br />
|
|
|
|