|
No, you can call a variation of shellexecute that returns the handle and then you call an API that waits for that process to finish.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Process.Start returns an instance of the Process class representing the program you started. Hence this should work (at least the idea, I did not run it):
Process.Start("\"" + lvi.SubItems[0].Text + "\"").WaitForExit();
|
|
|
|
|
Figured it out using HasExited. Thanks all.
|
|
|
|
|
I'm having trouble trying to determine if some arbitrary object can convert to type decimal. The underlying TypeConverters for int and decimal seem to think that an int can't be converted to a decimal. Now we all know that Convert.ToDecimal(someInt32Value) works just fine, but consider the following piece of code:
int n = 5;<br />
TypeConverter tc = TypeDescriptor.GetConverter(n);<br />
bool canConvert = tc.CanConvertTo(typeof(decimal));<br />
Can anyone see what I'm doing wrong? Is this a framework bug, or have I missed something?
NATHAN RIDLEY
Web Application Developer
email: snowdevil [@] gmail.com
!! Are you a skilled ASP.Net programmer or web designer and would like to help bring the best new ASP.Net CMS ( http://www.sprocketcms.com[ ^]) into the forefront of the ASP.Net community? Please contact me and let me know.
|
|
|
|
|
use ToString and then decimal.TryParse
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanks Christian. Seems like a bit of a roundabout way of doing it though. I ended up opting for a small function which simply compares the type to the list of existing types and does the conversion directly if it's a numeric type.
NATHAN RIDLEY
Web Application Developer
email: snowdevil [@] gmail.com
!! Are you a skilled ASP.Net programmer or web designer and would like to help bring the best new ASP.Net CMS ( http://www.sprocketcms.com[ ^]) into the forefront of the ASP.Net community? Please contact me and let me know.
|
|
|
|
|
Hello everybody.
I have a TabControl with two TabPages each contains one DatagridView control.
I want that, when i click on a row in First Datagridview (Customers),
Second DatagridView (Shopping List) refresh to show the according to that row.
I can do this, but I want to show "Date of shopping" in second Datagridview
RowHeader's Cell, When i'm going to TabPage2 i see all rows with
empty RowHeade. But when i back to TabPage1 and change the row and back again
to TabPage2 I can see RowHeader's value now!
Why i should click on some rows of first to setting RowHeader's
Value on second? How can i solve this?
<br />
dGridViewShopping.DataSource = ds;<br />
dGridViewShopping.DataMember = ds.Tables["tblShopping"].TableName;<br />
dGridViewShopping.Columns["date"].Visible = false;<br />
<br />
foreach (DataGridViewRow dgRow in dGridViewShopping.Rows)<br />
{<br />
if (dgRow.Index != dGridViewShopping.Rows.Count - 1)<br />
{<br />
dgRow.HeaderCell.Value = dgRow.Cells["date"].Value.ToString();<br />
}<br />
}<br />
Tanx
|
|
|
|
|
I'm trying to figure out why it is, when I close one form - which is supposed to set a property in my Main form to true - the property reverts back to false. The form is a basic logon screen that is supposed to return "true" to the Main form, and the main form is supposed to display itself. However the only way to get the main form to display itself is if I code the following:
if (!AuthenticUser)
{
copyrightRichTextBox.LoadFile(@"..\..\Supporting Files\Copyright.rtf");
}
This doesn't make logical sense to me. Can someone explain what may be happening here? Thanks.
Dre---
=======================
Every experience in life is a lesson to be learned
A. Stevens
B.S., Computer Science
|
|
|
|
|
if(!false)
{
dadada dada...
}
what's so "logically incorrect"??
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
DRAYKKO wrote: I'm trying to figure out why it is, when I close one form - which is supposed to set a property in my Main form to true - the property reverts back to false.
You're probably setting the property on a different instance of the form. Can you post that code ?
The code that sets the value of Authenticated user is what we really need to see here, I suspect.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
private void OK_Click(object sender, EventArgs e)
{
Main userAuthentication = new Main();
userAuthentication.AuthenticUser = CheckUser();
if (userAuthentication.AuthenticUser)
{
this.Close();
}
else
{
if (Tries < 2)
{
MessageBox.Show("That was an invalid user name or password. Try again...");
++Tries;
CheckUser();
}
else
{
userAuthentication.AuthenticUser = false;
this.Close();
}
}
}
public bool CheckUser()
{
if ((usernameTextBox.Text == "User1") && (passwordTextBox.Text == "User1"))
return true;
else if ((usernameTextBox.Text == "User2") && (passwordTextBox.Text == "User2"))
return true;
else
{
usernameTextBox.Text = "";
passwordTextBox.Text = "";
usernameTextBox.Focus();
return false;
}
}
This code, from the Logon form, is supposed to alert the Main form whether the user typed in a valid username and password. And when I "trace" it, it does set AuthenicUser to true. But it seems that when I close the logon form the property reverts back to false (and I'm not sure why).
BTW: Is there a way to send attachments here?
=======================
Every experience in life is a lesson to be learned
A. Stevens
B.S., Computer Science
|
|
|
|
|
DRAYKKO wrote: Main userAuthentication = new Main();
Like I thought. You're creating a new instance of the Main class, which has absolutely NOTHING to do with the instance in which you check this variable. You should create a variable inside this form and check it from your main instance, when you close the login dialog. Or, set up a delegate that gets called if login is successful.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thank you Christian!
I see the problem now.
As a solution I made the property and it's subsequent variable static bool (rather than just bool), so that they were accessible from the Logon form.
Thanks for your input, and help!!
Dre---
=======================
Every experience in life is a lesson to be learned
A. Stevens
B.S., Computer Science
|
|
|
|
|
Is it possible to get an Array with the Enum-Values from a FlagEnum-Value ?
I mean the following.
For example i have a enumation with flag-values like this:
<code>
public enum SampleEnum{
Alpha = 1,
Beta = 2,
Gamma = 4,
Delta = 8,
Epsilon = 16
}
...and now i got a variable like this:
<code>
private SampleEnum var = SampleEnum.Alpha | SampleEnum.Gamma | SampleEnum.Epsilon;
My question is now is there a simple way to bring that values...
<code>
SampleEnum.Alpha | SampleEnum.Gamma | SampleEnum.Epsilon
... in an array where the array contains the enum values of the flag-enum-value like this:
<code>
private SampleEnum[] varArray = new SampleEnum[3];
SampleEnum[0] SampleEnum.Alpha
SampleEnum[1] SampleEnum.Gamma
SampleEnum[2] SampleEnum.Epsilon
I tried something like the following but it dont work =/
<code>
private SampleEnum var = SampleEnum.Alpha | SampleEnum.Gamma | SampleEnum.Epsilon;
private SampleEnum[] varArray = (SampleEnum[]) var ;
I hope you know what i mean.
|
|
|
|
|
Hi,
have a look at Enum.GetValues() !
PS: It is wise to add the [Flags] attribute if your enum contains only flags
|
|
|
|
|
No, dont want all values of the enum .....i just want the enum-values of the variable.
Scott Dorman understood it right
|
|
|
|
|
You can "cheat" as long as the enum is decorated with the Flags attribute by using the following code:
SampleEnum var = SampleEnum.Alpha | SampleEnum.Gamma | SampleEnum.Epsilon;
string[] varArray = var.ToString().Split("|"); This will give you a string array containing the three enum values as a string. You could then turn each string value back to it's enum value by using Enum.Parse .
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
hmm thanks, i thought about that solution already but i hoped that there are an better way to do this.....
At least i could write a methode that returns an array with the values like this:
public static Enum[] GetArrayFromFlagEnumValue( Enum flagEnumValue ) {
Type flagEnumType = flagEnumValue.GetType();
object[] attributes = flagEnumType.GetCustomAttributes( typeof( FlagsAttribute ), false );
if( attributes.Length > 0 ) {
List<Enum> enumValueArray = new List<Enum>();
int flagEnumIntValue = Convert.ToInt32( flagEnumValue );
int tmpEnumIntValue = new int();
Array reversedEnumValues = Enum.GetValues( flagEnumType );
Array.Reverse( reversedEnumValues );
foreach( Enum enumValue in reversedEnumValues ) {
tmpEnumIntValue = Convert.ToInt32( enumValue );
if( ( flagEnumIntValue - tmpEnumIntValue ) >= 0 ) {
flagEnumIntValue = flagEnumIntValue - tmpEnumIntValue;
enumValueArray.Add( enumValue );
}
}
enumValueArray.Reverse();
return enumValueArray.ToArray();
}
else {
throw new ArgumentException( "The enumation of this value is not marked with the required FlagsAttribute!", "Enum value" );
}
}
</code>
|
|
|
|
|
Hi, i have a problem here, i want to add items to an arraylist that is public in a form
im creating some threads so i try to add items to it from the threads but it doesnt work have a ny idea why.
I already resolve one prob similar but i cant find the asw to this, this prob was that i want to access a listbox from the thread, and what i do was this:
delegate void SetTextCallback(ArrayList text);
private void SetText(ArrayList text)
{
// InvokeRequired required compares the thread ID of the
// calling thread to the thread ID of the creating thread.
// If these threads are different, it returns true.
try
{
if (this.Boxestado.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetText);
this.Invoke(d, new object[] { text });
}
else
{
for (int i = 0; i <= id.Count; i++)
{
this.Boxestado.Items.Add(text[i]);
}
}
hilo.Abort();
}
catch(Exception)
{
}
}
im trying to understand that it might be a metodh or a safe way to acces object that are running in other methods but with the arraylist i cant figureout this is the code for the thread
public void identificacion()
{
// Se crea un nuevo objeto de la clase Socket_ Server
// se genera el estado escuchar y se espera hasta que algun
// cliente responda
Socket_Server identificacion;
identificacion = new Socket_Server();
id = identificacion.Begin(ip, puerto);
this.SetText(id);
//HERE IS where I WANT TO ADD items from the id wich is a ArrayList to another Arraylis Cln
//so THAT way every time the thread is executed i could be added the items in the id arraylist
// to de Cln, wich its going to have all the items that have been added in some loop.
ejecutar_hilo_identificacion();
}
public void ejecutar_hilo_identificacion()
{
Thread hilo = new Thread(new ThreadStart(identificacion));
hilo.IsBackground = true;
hilo.Start();
}
|
|
|
|
|
Hi,
if you want to manipulate an ArrayList (or anything else for that matter) from
inside multiple threads, then you should give those threads mutual exclusion access
to the ArrayList (so at any point in time at most one thread is manipulating it).
The easiest way is to use the lock keyword.
And yes you are right, you need InvokeRequired and Invoke in order to modify
some Control from any thread that is not the UI thread.
|
|
|
|
|
Hello everyone,
I have a ContextMenu in my Windows Application and I am trying to change it's property but I am unable to do so. For some reason when I change the size of the "Seperator" it goes back to what it was before!!!
Can someone tell me what is going on here and how I can change the size of seperators in my ContextMenu.
Thank you very much and have a great day
Khoramdin
|
|
|
|
|
Hi,
you should be able to draw a menu item yourself, by setting OwnerDraw true, and
providing MeasureItem and DrawItem event handlers.
|
|
|
|
|
Hello Luc,
Thanx for the help. If I am not mistaken base on your suggestion I can customize the entire ContextMenu. That is something which I might consider if there is no other way to get what I am looking for.
The problem is what I am looking for is very simple. I wish to reduce the width of the seperator in the ContextMenu as it overlaps the image that I have placed on the left hand side of the ContextMenu.
Thanx for your help, mate.
Khoramdin
|
|
|
|
|
hi
for change the size property u must first set autosize property to false.
|
|
|
|
|
Hello Maryamf,
Thanx for the reply. That is what I thought initially and believe me when I tell you that I tried it. for some reason the Hight works fine but Width setting is not working. It is fix to what it was picked initially by the Contoller. All I wish to do is to reduce the width of the "Seperator" and align in to the left. Just the way the ContextMenu in Visual Studio is!
Thank you for your help, mate.
Khoramdin
-- modified at 13:23 Sunday 15th April, 2007
|
|
|
|