|
pippyn wrote: I think my best bet, if I'm required to move forward with ths project, is to get a seperate development pc and recreate the old environment, probably with evc4, and go from there.
Best bet. Using MS's or VMWare's Virtual PC would probably be a good idea to put the dev environment under.
pippyn wrote: As for developing with classes that run with any version, that's great advice after the fact. Even then, I specifically chose the newer class because the hardware manufacturer was discontinuing support on the older class.
Best case against doing it, right there. The hardware is probably going to last another year, at best, before they want upgraded stuff.
|
|
|
|
|
I am aware of how to close a form. But, in a project I have been working on, the from cannot be created regularly. My Program.Cs looks like this:
static void Main()<br />
{<br />
Application.EnableVisualStyles();<br />
Application.SetCompatibleTextRenderingDefault(false);<br />
CreateForm(true);<br />
Application.Run();<br />
}<br />
<br />
public static void CreateForm(bool blIsClosing)<br />
{<br />
frmMain frmFace = new frmMain();<br />
<br />
if (blIsClosing == true)<br />
{<br />
frmFace.Close()<br />
}<br />
}
So, my question is, from the form that I have created, how can I close it. I can call theFrm.Close(), and the form will dissapear, as well as my tray icon. But, the program is still running(as in Visual Studio still sees the form as running) How Can I close the form, and actually kill the process from the form that I have created?
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
Use
Application.Run(new frmMain());
instead of a CreateForm method. Handle the Load event of your form to perform some start-up procedures.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
Application.Run() starts a message loop without a form. The application will not quit until you make a call to Application.Exit() . I am not sure what you are trying to accomplish and why you just didn't call Application.Run([MainWindowGoesHere]) . If you are trying to create a tray-based application, you may want to create a main window that is always invisible and control the application from there.
|
|
|
|
|
I want hide or disable MyComputer or drives of the computer so that, after restarting the computer , MyComputer or drives is restored to normal state (visible/enable)
can any body help me?
H.R
|
|
|
|
|
This is usual done through a domain policy, not sure it if be done on non domain machines and better answers will be found in Tech net.
|
|
|
|
|
I have 2 forms. On Form1 I have two listboxes. I want to allow the user to edit items in either listboxes by the use of two edit buttons (associated with 1 listbox each). When an item in listbox1 is selected then no items in listbox2 are selected (and vic versa). So when the first edit button is clicked to edit the selected item in listbox2, form2 is shown with a textbox. In this textbox is the text of the selected item. This should work the same for the second edit button but the selected item in listbox2 should be shown in the textbox on form2. To do this I have created two public strings and two public bools in form1:
public string item1
{
get { return listBox1.SelectedItem.ToString(); }
}
public bool selectedItem1
{
get { return Convert.ToBoolean(listBox1.SelectedIndex) == true; }
}
public string item2
{
get { return listBox2.SelectedItem.ToString(); }
}
public bool selectedItem2
{
get { return Convert.ToBoolean(listBox2.SelectedIndex) == true; }
}
In form2's load event I have the following if statement to check if listbox1 has a selected item or if listbox2 has a selected item:
if (Form1.selectedItem1 == true)
{
textBox1.Text = Form1.item1;
}
else if (Form1.selectedItem2 == true)
{
textBox1.Text = Form1.item2;
}
I have used a break point to follow this if statement and it seems as though it is not checking which listbox has an item selected.
Can anyone help please? How can I check which listbox has a selected item. Or can I turn this code into a public bool variable?:
if (listBox1.SelectedIndex >= 0)
Lucy
|
|
|
|
|
Hi,
are the listbox items selected when the form loads?
what happens when the selection changes after form load?
My view (assuming you can select at most one item per listbox):
- add OnSelectedIndexChanged event handlers;
- do all your related stuff in there;
- don't be surprised if OnSelectedIndexChanged also fires when an item gets unselected;
- there is no need for separate variables such as selectedItem1, adding them increases
the chance your object state becomes inconsistent, and that would make debugging much
more complex.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thank you for your comment.
Form2 can only load when a listbox item is selected. I already have a SelectedIndexChanged event for each listbox that has an if statement similar to this:
if (listBox1.SelectedIndex >= 0)
{
buttonEdit1.Enabled = true;
listBox2.SelectedIndex = -1;
}
else
{
buttonEdit1.Enabled = false;
}
Lucy
|
|
|
|
|
list box has event that its name is
"SelectedIndexChanged"
you can work with it .
bye
ali sardar
|
|
|
|
|
Lucy_H85 wrote: To do this I have created two public strings and two public bools in form1:
Lucy, have you heard about Object Oriented Design? Software Design Patterns?
Here is one that pertains to your post[^]
|
|
|
|
|
Yes this is what I am currently learning. Sorry I am not an expert yet.
Lucy
|
|
|
|
|
Lucy_H85 wrote: Yes this is what I am currently learning
So am I. I doubt I will ever stop learning.
Lucy_H85 wrote: Sorry I am not an expert yet.
Neither am I, no need to apologize.
|
|
|
|
|
Ok so I am confused.
What happends memory wise when I pass an instance of a class as a method parameter, for e.g.:
public class ClassA
{
}
public class ClassB
{
public string GetClassName(ClassA classA)
{
classA.OtherMethodClass();
return classA.ToString();
}
}
public class ClassC
{
ClassA a = new ClassA();
ClassB b = new ClassB();
string x = b.GetClassName(a);
Console.WriteLine(x);
}
Now does a new object get created in memory when I pass the class instance? Or would any changes made to the method parameter would also effect the actual object? Just need some clarification.
Thanks for your help.
|
|
|
|
|
You only pass a reference to the object.
Objects are never copied in .NET unless you specifically copy them.
---
single minded; short sighted; long gone;
|
|
|
|
|
So if I make any changes to the object passed through the method parameter, those changes will also effect the actual object?
public class ClassA
{
public ClassA()
{}
public string Color = "orange";
}
public class ClassB
{
public ClassB(){}
public string GetClassName (ClassA classA)
{ classA.Color = "red";
classA.OtherMethodClass();
return classA.ToString();
}
}
public class ClassC
{
public ClassC()
{
ClassA a = new ClassA();
Console.WriteLine(a.Color.ToString());
ClassB b = new ClassB();
string x = b.GetClassName(a);
Console.WriteLine(a.Color.ToString());
a.Color = "Green";
}
}
|
|
|
|
|
Yes it will write "red".
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
And if you pass a ValueType like int, DateTime, ... then a copy is passed to the method, as long as you do not mark them with ref or out. The copy is then pushed to the Stack where the method gets it from.
-^-^-^-^-^-
no risk no funk ................... please vote ------>
|
|
|
|
|
Guffa answered your question correctly for class instances: passing a class instance to a method will *NOT* copy it; you're passing a pointer to that instance.
As Urs mentioned, if you pass a struct instance (say, a System.Int32, a DateTime, or your own custom struct), it *WILL* pass a copy of the struct instance to the method.
In summary: class instances are passed by reference (no copying going on), and struct instances are passed by value (copying).
As a side note, if you do want to pass values by reference, you can do so using the ref keyword.
|
|
|
|
|
Does anyone know of a cipher that will convert/encrypt any printable characters into all upper-case letters? Essentially I would like to be able to convert the output of a DES encryption, which can contain numbers, letters or special characters, into all upper-case letters. Does anyone know of any code, no matter how simple, that can provide that function?
Thanks...
|
|
|
|
|
Decrypt it. Convert it to upper case. Re-encrypt it.
You cannot convert it to upper case while it is in its encrypted state.
|
|
|
|
|
do you mean convert the crypttext into something that looks like ABLKSJFHUIWKLDHALSDHQWE... or to capitalize the contents of the encrypted text while keeping it encrypted? The later as the other poster mentioned is impossible. The simplest way to do the former would be to map each 8 bit value onto one of the first 256 2 upper case character pairs. eg
0x00 = AA
0x01 = AB
..
0x1A = AZ
0x1B = BA
...
--
If you view money as inherently evil, I view it as my duty to assist in making you more virtuous.
|
|
|
|
|
dan neely wrote: do you mean convert the crypttext into something that looks like ABLKSJFHUIWKLDHALSDHQWE...
Yes, and your suggestion should work fine for what I want to do...
Thank you.
|
|
|
|
|
Or you could try UUEncoding, which isnt exactly what you have requested, but at least you wont be reinventing the wheel.
|
|
|
|
|
Although not strictly letters, maybe a simple hex representation is sufficient,
i.e. replace each encrypted byte by two characters in [0-9A-Z].
byte.ToString("X2") would do that for you.
And byte.Parse(string, NumberFormat.HexNumber) would undo it.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|