
I'd expect a delegate to be faster because data binding goes through reflection, but there won't be much difference. Neither should be a bottleneck in a real system.





Hi Everyone!
My problem might be very easy for you but I am having difficulty trying to solve this.
I have a menu strip on my form. Currently it occupies only half the size of my form. What I am trying to do is make the menu strip items occupy the entire form, and when the form resizes, it will also adjust its height and/or width.
I tried setting the auto size property of the menu strip but it does not solve the problem.
Do you have any ideas guys on how to solve this? I will appreciate any kind of solution.
Thanks folks!





That's how MenuStrip (in fact ToolStrip , from which it derives) works. You can manually override this behavior by handling the form's resize event and increasing/decreasing the Margin property of each toplevel menu item.
/ravi





If this is Windows Forms, an instance of a MenuStrip Control dragged on to a Form at designtime should automatically dock to the top of the Form, and fit to the entire width of the Form: that's an outcome of its default Dock Property, which is DockStyle.Top. At runtime the MenuStrip will expand, or contract, so it's always the width of the Form.DisplayRectangle.Width.
So, I am not sure I understand your question: are you perhaps wishing to have whatever Controls or MenuItems in your MenuStrip somehow distributed across the current width of the Form ?
If you seek to aid everyone that suffers in the galaxy, you will only weaken yourself … and weaken them. It is the internal struggles, when fought and won on their own, that yield the strongest rewards… If you care for others, then dispense with pity and sacrifice and recognize the value in letting them fight their own battles." Darth Traya





BillWoodruff wrote: Controls or MenuItems in your MenuStrip somehow distributed across the current width of the Form I think (i.e. I assumed) that's what the OP wants to do. Goes against the standard and what users expect, IMHO.
/ravi





Hmm, yeah your right BiillWoodruff, it occupies the entire width but the items does not expand to maximize the remaining spaces, what I wish/want is that menu strip items are distributed across the width of the form, leaving no empty spaces.
Sorry for the confusion. Do you have solution in mind?





I don't know of a solution or an an example. The reason is because you're going against all normal practices and what Microsoft has baked into Windows. The philosophy is that users must have a consistent experience acrossed all applications. Controls that look the same should all work the same so as to not confuse users.
In order to do what you want, I believe you would have to owner draw the entire menu, or come up with your own menu controls without using the standard toolbox ones.





Thanks Dave for the reply,
Of course, I don't want user of the application to get confused, it will just expand or shrink depending on user form size or user monitor size if maximized or the reverse. The menu item is still there, it will be always visible to user, it will not change the order, just the height or width.
yeah, I might going against what microsoft baked but I find it challenging and I believe we all like challenges right?
Thanks again.





Did my solution not work?
/ravi





Thanks Ravi!
I haven't tried it out yet, I will let you know if it works.
Thanks for the idea!
Cheers!





Hey Ravi, I tried your suggestion regarding setting the margin. Hmm, but I did not achieve what I want, it just put padding on the menu strip as a whole. I want to share you what I did. See code below.
private void ResizeMenu()
{
int itemHeight = (int) (Math.Floor((double)(this.Size.Height / (this.menuStrip1.Items.Count + 1))));
foreach (ToolStripMenuItem item in this.menuStrip1.Items)
{
int prevWidth = item.Size.Width;
item.Size = new Size(prevWidth, itemHeight);
}
}
Sorry I can't format nicely my code here. I am calling the method when form resizes.
Thanks for your help!





That's not what I meant. Change each item's Margin property instead (specifically the .Left member).
/ravi





hi,
I have a FTP location from where i want to get files, which are created on a date which is saved in the local machine.
Is it possible to do that,when i searched the data is retrieved as stream , where i cant give a filter condition. (with my knowledge)
Please suggest a solution.
Thanks
Sandeep





You may want to use NetFTP[^].
/ravi





http://www.codeproject.com/Questions/163452/howtogetthelatestfileinaFTPordirectoryu
got the solution





How to access remote file directories without permission from remote system.





You want us to tell you how to get files that the ownere doesn't want you to have? No chance!
=========================================================
I'm an optoholic  my glass is always half full of vodka.
=========================================================





hi
how can move a rectangle over desktop area and taking picture.i want to be able to move the rectangle around pressing left mouse cursor and keep capturing pictures.
your help is greatly appreciated
abol







Hello
How to Get bound of full screen without taskbar c#
thanks





Rectangle r1 = Screen.PrimaryScreen.Bounds;
Rectangle r2 = Screen.PrimaryScreen.WorkingArea;
int tBarHeight = r1.Height  r2.Height; If the TaskBar is not autohidden then the r1.Height  r2.Height gives you the height of the TaskBar.
However, if your goal is to show a fullscreen Window, you should not really concern yourself with the TaskBar: see Raymond Chen's MS blog entry:[^].
Remember that the user may have docked the TaskBar to another side of the screen, and, that there could be multiple monitors in use.
"What Turing gave us for the first time (and without Turing you just couldn't do any of this) is he gave us a way of thinking about and taking seriously and thinking in a disciplined way about phenomena that have, as I like to say, trillions of moving parts.
Until the late 20th century, nobody knew how to take seriously a machine with a trillion moving parts. It's just mindboggling." Daniel C. Dennett






Hello would someone please help me with my program, I'm stuck all day with this thing. The program runs, but I think the problem is a logical error. The fraction 1/4 + 2 1/2 should be equal to 2 3/4 but the program's result is 2 3/8. Another thing is the expression 1/8 + 2 1/2 should be equals to 2 5/8. Please help me how to fix the codes. Thank you very much!
using System;
class FractionDemo
{
static void Main(string[] args)
{
Fraction firstfraction = new Fraction();
Fraction secondfraction = new Fraction();
firstfraction.Numerator = 1;
firstfraction.Denominator = 4;
secondfraction.Numerator = 1;
secondfraction.Denominator = 8;
secondfraction.WholeNumber = 2;
Fraction add = new Fraction();
add = firstfraction + secondfraction;
Console.Write("\n {0}/{1}", firstfraction.Numerator, firstfraction.Denominator);
Console.WriteLine(" + {0}/{1} = {2}/{3}", secondfraction.Numerator, secondfraction.Denominator, add.Numerator, add.Denominator);
Console.Write("\n {0}/{1}", firstfraction.Numerator, firstfraction.Denominator);
Console.WriteLine(" + {0} {1}/{2} = {3} {4}/{5}", secondfraction.WholeNumber, secondfraction.Numerator,secondfraction.WholeNumber, add.WholeNumber, add.Numerator, add.Denominator);
Console.Write("\n {0}/{1}", firstfraction.Numerator, secondfraction.Denominator);
Console.WriteLine(" + {0} {1}/{2} = {3} {4}/{5}", secondfraction.WholeNumber, secondfraction.Numerator, secondfraction.WholeNumber, add.WholeNumber, add.Numerator, add.Denominator);
Console.ReadLine();
}
public class Fraction
{
private int wholenumber;
private int numerator;
private int denominator;
public int WholeNumber
{
get
{
return wholenumber;
}
set
{
wholenumber = value;
}
}
public int Numerator
{
get
{
return numerator;
}
set
{
numerator = value;
}
}
public int Denominator
{
get
{
return denominator;
}
set
{
denominator = value;
if (denominator > 0)
{
denominator = value;
}
else
{
denominator = 1;
}
}
}
public Fraction(int wholenumber, int numerator, int denominator)
: this(numerator, denominator)
{
WholeNumber = wholenumber;
}
public Fraction(int numerator, int denominator)
{
WholeNumber = 0;
Numerator = numerator;
Denominator = denominator;
}
public Fraction()
{
WholeNumber = 0;
Numerator = 0;
Denominator = 1;
}
public int gcd()
{
int x = Numerator;
int y = Denominator;
int m;
if (x > y)
m = y;
else
m = x;
for (int i = m; i >= 1; i)
{
if (x % i == 0 && y % i == 0)
{
return i;
}
}
return 1;
}
public void Reduce()
{
int gcdNum = gcd();
if (gcdNum != 0)
{
Numerator = Numerator / gcdNum;
Denominator = Denominator / gcdNum;
}
if (Denominator < 0)
{
Denominator = Denominator * 1;
Numerator = Numerator * 1;
}
convertFraction();
}
public void convertFraction()
{
WholeNumber = Numerator / Denominator;
Numerator = Numerator % Denominator;
}
public static Fraction operator +(Fraction firstfraction, Fraction secondfraction)
{
int firstNum = (firstfraction.WholeNumber * firstfraction.Denominator) + firstfraction.Numerator;
int secondNum = (secondfraction.WholeNumber * secondfraction.Denominator) + secondfraction.Numerator;
Fraction Result = new Fraction();
Result.Numerator = firstNum * secondfraction.Denominator + firstfraction.Denominator * secondNum;
Result.Denominator = firstfraction.Denominator * secondfraction.Denominator;
Result.Reduce();
return Result;
}
}
}





Um.
No, it's your test code that is the problem:
Console.Write("\n {0}/{1}", firstfraction.Numerator, firstfraction.Denominator);
Console.WriteLine(" + {0} {1}/{2} = {3} {4}/{5}", secondfraction.WholeNumber, secondfraction.Numerator, secondfraction.WholeNumber, add.WholeNumber, add.Numerator, add.Denominator);
Console.Write("\n {0}/{1}", firstfraction.Numerator, secondfraction.Denominator);
Console.WriteLine(" + {0} {1}/{2} = {3} {4}/{5}", secondfraction.WholeNumber, secondfraction.Numerator, secondfraction.WholeNumber, add.WholeNumber, add.Numerator, add.Denominator);
Why are you printing the whole number in two places:
1/4 + 2 1/2 = 2 3/8
^
1/8 + 2 1/2 = 2 3/8
^
If you change the third parameter value to the Denominator:
Console.Write("\n {0}/{1}", firstfraction.Numerator, firstfraction.Denominator);
Console.WriteLine(" + {0} {1}/{2} = {3} {4}/{5}", secondfraction.WholeNumber, secondfraction.Numerator, secondfraction.Denominator, add.WholeNumber, add.Numerator, add.Denominator);
Console.Write("\n {0}/{1}", firstfraction.Numerator, secondfraction.Denominator);
Console.WriteLine(" + {0} {1}/{2} = {3} {4}/{5}", secondfraction.WholeNumber, secondfraction.Numerator, secondfraction.Denominator, add.WholeNumber, add.Numerator, add.Denominator);
Then the math is correct for the second line:
1/4 + 2 1/8 = 2 3/8
but still wrong for the third, since that isn't the sum you are doing!
1/8 + 2 1/8 = 2 3/8




