|
Besides albean suggestion, which makes it very flexible for extending parameters, you can always set properties of a class and pass this class as a parameter to your Report constructor.
Acting as a substitute for God, he becomes a dispenser of justice. - Alexandre Dumas
|
|
|
|
|
Martin Fowler had a solution for this type of problem in Refactoring with Introduce Parameter Object (p. 295). The concept is to "Create a new class to represent the group of parameters you are replacing."
ReportParams rp = new ReportParams (StartDate, EndDate, NameID, LocID);
Report report = new Report (rp);
Your new parameter object could have all the permutations of parameters and remove those details from the Report class.
α.γεεκ Fortune passes everywhere. Duke Leto Atreides
|
|
|
|
|
Off to Amazon.com I guess. Thanks for the tip.
|
|
|
|
|
Hi Yallz,
I have a list box that you can edit the items in (click a button, and it pops up a form so you enter the info you want), the problem I'm encoutering is that once the user presses OK on the edit form the listbox isn't update with the new informatin. Is there anyway to update a listbox item without removing it and then adding it back?
Thanks!
- monrobot13
|
|
|
|
|
Are you doing something like this in your click event:
MyForm f = new MyForm();
f.Show();
If you are then your problem is you are getting a NEW form each time with an empty list.
Try hiding the listbox form when you are done with it. In the button click event unhide it.
|
|
|
|
|
That's not it. I actually serialize all the listbox items when the form is closed and then deserialize them when it's loaded. When I do this it does show the new information.
When you add an item to a listbox it call's it ToString function to get the text to display. I want to update the text that is being displayed without removing and readding the item.
- monrobot13
|
|
|
|
|
Don't use ToString().
Add the item itself, or better yet use databinding to display a complete collection. When you edit the collection entry, the listbox is updated (possibly after a call to Refresh()).
|
|
|
|
|
Does anyone know what the C# WinForm equivalent is of the old VB6 DoEvents() method on forms???
This is the process where a tight loop will allow the form to process events before going back into its' loop.
Thanks!
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
Application.DoEvents(). But in many cases it's better to use multiple threads.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Well...I have the methods I am calling broken out into a DLL. And I did find the Application.DoEvents() to be fairly non-responsive. (2 or 3 button clicks to end the process)
But I'm not really familiar with spawning threads in a WinForm client. What are the basic steps I would need to do to make the component an independant thread? Or if you know of a tuturial...?
Thanks,
MJ
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
There's sure to be one on CodeProject somewhere, but here's a brief example:
using System.Threading;
Thread thread=null;
thread=new Thread(new ThreadStart(this.ThreadMethod));
thread.IsBackground=true;
thread.Start();
Thread.Sleep(0);
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Does anybody know how I can access the MessagBoxIcons directly? I want to stick one on a Form (not a MessageBox). Is there some sort of internal imagelist in the Framework?
|
|
|
|
|
If you use Reflector to decompile the .net framework you will see that the native MessageBox method is called. The MessageBoxIcon is just an enum. The value is passed to the native func as an int.
I suggest opening the native lib with VS.NET and ripping the icons.
|
|
|
|
|
in this folder : ( where your drive goes inplace of " D " )
D:\Program Files\Microsoft Visual Studio .NET\Common7\Graphics\icons
there you will find them , listed under " Computer " i think , although they are embeded in .net for the messagebox's
Vb:
<font color="blue">Public Function</font> TwinsOnWay(<font color="blue">ByVal</font> twins <font color="blue">As String</font>) <font color="blue">As String <br> Select Case</font> twins<br> <font color="blue">Case</font> "Gender" <br> <font color="blue">Return</font> "Two Girls" <br> <font color="blue">End Select <br> End Function</font> <br>
|
|
|
|
|
The icons are not part of the .NET Framework. The internal implementation of MessageBox.Show just calls the Platform SDK function MessageBox , passing a flag value that specifies the icon you want displayed. The icons themselves are stored as resources in user32.dll.
|
|
|
|
|
Hey all,
How can I create a get/set method that returns the Nth item of an array?
|
|
|
|
|
What do you mean?
The easiest way is to just do array[x]
What exactly are you trying to do?
|
|
|
|
|
Well, I have a class Foo(). Inside Foo is a private array of another class, Bar().
public Foo()
{
private Bar[] myBars = new Bar[10];
}
When I instantiate Foo, I need to be able to assign a value to the array of Bars:
myFoo.myBars[n].someValue = 10;
So how can I do this?
|
|
|
|
|
Such a property is called an indexer. You can read a tutorial on them in the MSDN documentation (under "indexers->tutorial (C#)")The following is an example...
public class MyArray {
...
public Object this[int index] {
get {
return _Items[index];
}
set {
_Items[index] = value;
}
}
private Object[] _Items;
}
|
|
|
|
|
I am having trouble figuring out how to progamatically save images from a website using this class. I tried this:
private void SaveImages(string url)
{
int s = Application.StartupPath.IndexOf("bin\\Debug");
Bitmap img = new Bitmap(url);
img.Save(Application.StartupPath.Remove(s,9) + "image1.gif", ImageFormat.Jpeg);
} I get this error message though:
URI formats are not allowed.
Do I have to use a stream object to do this? If so how do I load the remote image into the stream?
Thanks cause I'm lost;)
Steve
McLenithan
Is Bert Evil? | Homer: "Hello, operator, gimme the number for 911!"
|
|
|
|
|
here ya go , by chance i built this a few days ago to help someone on another forum
C#:
<font color="blue">private</font> <font color="blue">void</font> button1_Click(<font color="blue">object</font> sender, System.EventArgs e) <br> { <br> System.Net.WebClient web=<font color="#0000FF">new</font> System.Net.WebClient(); <br> System.IO.StreamReader sr=<font color="#0000FF">new</font> System.IO.StreamReader(web.OpenRead("http://www.codeguru.com/forum/images/icons/icon8.gif")); <br> System.Drawing.Image i=System.Drawing.Image.FromStream(sr.BaseStream); <br> <font color="DarkGreen">
hope it helps
Vb:
<font color="blue">Public Function</font> TwinsOnWay(<font color="blue">ByVal</font> twins <font color="blue">As String</font>) <font color="blue">As String <br> Select Case</font> twins<br> <font color="blue">Case</font> "Gender" <br> <font color="blue">Return</font> "Two Girls" <br> <font color="blue">End Select <br> End Function</font> <br>
|
|
|
|
|
[Mr. Burns Eexxcellent!] Thanks dynamic
Steve
McLenithan
Is Bert Evil? | Homer: "Hello, operator, gimme the number for 911!"
|
|
|
|
|
Also ....
Instead of using .Remove(s,9) you can use the System.IO.Path static methods: GetParentDirectory()
|
|
|
|
|
Thanks AK. I didn't even realize that was there;)
Steve
McLenithan
Is Bert Evil? | Homer: "Hello, operator, gimme the number for 911!"
|
|
|
|
|
I have a XML setting file which has symbol "&" inside.The below code
got exception from ReadXML since the "&"
DataSet ds = new DataSet();
ds.ReadXml(m_xmlPath);
Please help me how to use ReadXML or other methods to solve the problem.
|
|
|
|