|
I want to place all disks in a combo box, so how do I list them?
|
|
|
|
|
|
Hi,
I wanted to know how to get my C# application to have separate configuration files for each user on the same machine.
I have an application called 'myapp.exe' that needs to store user-specific configuration information, preferably in the 'ROOT:\\documents and settings\<user_name>\application data\myapp\useroptions.xml'. I know I can use ConfigurationSettings.Appsettings to read the 'myapp.exe.config' file and get application settings that way but that file must reside in the application folder.
Any ideas?
|
|
|
|
|
|
|
I remember seeing an article on replicating functionality that is avaliable in windows explorer, but cannot seem to find it. If you open up windows explorer, on the left side bar you can collapse and uncollapse areas of the bar such as system task and other places. The article explained how to do that. Any one know how to best find it?
|
|
|
|
|
|
Hey!
Why are the SerialPort freezing when closing?
Its offen no problem when it is a slow data flow, but if it fast then it Freezes?
I have tryed som diffrent things, ex
using Dispose insted
seting boudrate to 1
But this is not helping?
Do you got any ide?
Best Regards
SnowJim
|
|
|
|
|
this is how my close looks like
<br />
public bool closePort()<br />
{<br />
try<br />
{<br />
RUNNING = false;<br />
if (serialPort != null)<br />
{<br />
if (serialPort.IsOpen)<br />
{<br />
lock (serialPort)<br />
{<br />
Thread.Sleep(500);<br />
serialPort.Dispose();<br />
}<br />
}<br />
serialPort = null;<br />
}<br />
return true;<br />
}<br />
catch (Exception ex)<br />
{<br />
addError("Error in " + this.ToString() + " - closePort : " + ex.Message);<br />
serialPort = null;<br />
return false;<br />
}<br />
}<br />
Is this not right?
i forgot to say that i also have an event
<br />
RUNNING = true;<br />
serialPort.ReceivedEvent += new SerialReceivedEventHandler(serialPort_ReceivedEvent);<br />
But this shold not be the problem, i can see the dataflow but not closing the serialport
|
|
|
|
|
Hey again!
If i change to this code, the program is not Freezing but i get an error :
<br />
public bool closePort()<br />
{<br />
try<br />
{<br />
dataCollector.stopWrite();<br />
RUNNING = false;<br />
if (serialPort != null)<br />
{<br />
if (serialPort.IsOpen)<br />
{<br />
<br />
try<br />
{<br />
<br />
Thread.Sleep(500);<br />
serialPort.Close();<br />
<br />
}<br />
catch (Exception ex)<br />
{<br />
serialPort = null;<br />
MessageBox.Show(ex.Message);<br />
return true;<br />
}<br />
}<br />
serialPort = null;<br />
}<br />
return true;<br />
}<br />
catch (Exception ex)<br />
{<br />
addError("Error in " + this.ToString() + " - closePort : " + ex.Message);<br />
serialPort = null;<br />
return false;<br />
}<br />
}<br />
There is no siurce code available for the current location
And this error occurs when serialPort.close() is runned
If i press ok on this error i get the following error:
ArgumentNillException was unhandled
value can not be null.
Is there any nice way to close this serial port with out errors.
Best Regards
SnowJim
|
|
|
|
|
Hello,
I'm writing an application where I have to perform this long process, so I create a new thread to keep the UI responsive. I also create a progress form which I have on my main thread. The code looks like this:
void StartProcess()
{
ProgressForm form = new ProgressForm();
WorkerClass wc = new WorkerClass(progressForm, delegate and so on);
Thread t = new Thread(new ThreadStart(wc.Run));
t.IsBackgroundThread = true;
form.Show();
t.Start();
Application.Run(form);
return;
} My idea is to create the thread and the form, display the form, and then start the thread. Also, I want the StartProcess routine to block until the process is completed. I tried form.ShowDialog after calling t.Start , but then the progress dialog misses some progress updates.
I want to create the form as modeless, disabling the parent (not shown in the code) and then start the thread. After that, I want to run a secondary message loop until the dialog is closed, and then return to caller. But I get an exception about it being invalid to create a secondary message loop on a single thread, to use From.ShowDialog or Application.RunDialog instead. But Application.RunDialog doesn't exist (it does, but it's internal .)
So, how can I do it?
[EDIT: I just tried the following code and it seems to work fine:
progressForm.Owner = formParent;
formParent.Enabled = false;
progressForm.Show();
thread.Start();
while(progressForm.Visible)
Application.DoEvents();
progressForm.Close();
formParent.Activate();
formParent.Enabled = true; Any comments on it?]
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
I suspect that's because StartProcess is called from a thread that already has a message loop. Are you calling start in response to an UI action, like clicking a button? In that case, the call to StartProcess comes on a thread that has a message loop, so when you call Application.Run again, it throws an exception.
form.ShowDialog should work fine. Are you sure you are using Invoke/BeginInvoke when trying to access method/properties on progressFrom from within WorkerThread? If you are not using Invoke/BeginInvoke, the UI won't be updated properly. form.Show should also work fine, as it is called from a thread running a message loop.
The solution then is to remove the line that calls Application.Run and make sure you use Invoke/BeginInvoke like
void StartProcess()
{
ProgressForm form = new ProgressForm();
WorkerClass wc = new WorkerClass(progressForm, delegate and so on);
Thread t = new Thread(new ThreadStart(wc.Run));
t.IsBackgroundThread = true;
form.Show();
t.Start();
return;
}
class WorkerThread
{
ProgressForm progressForm;
public WorkerThread(ProgressForm progressForm) {...}
public void Run()
{
while (true)
{
progressForm.UpdateStatus();
}
}
}
class ProgressForm
{
private delegate void EmptyParametersDelegate();
public void UpdateStatus()
{
if (this.InvokeRequired)
{
this.Invoke(new EmptyParametersDelegate(UpdateStatus), null);
return;
}
this.progressBar.Value = x;
}
}
Regards
Senthil
_____________________________
<font face="Verdana" size="1"><a href="http://blogs.wdevs.com/senthilkumar">My Blog</a> | <a href="http://www.codeproject.com/script/articles/list_articles.asp?userid=492196">My Articles</a> | <a href="http://geocities.com/win_macro">WinMacro</a></font>
|
|
|
|
|
Hi, I generate code (codigo) dinamcally and then complile it in memory for showit in propertyGrid
<br />
parametros.ReferencedAssemblies.Add("System.dll");<br />
parametros.ReferencedAssemblies.Add("System.Data.dll");<br />
parametros.ReferencedAssemblies.Add("System.Design.dll");<br />
parametros.GenerateInMemory = true;<br />
CompilerResults compilado = compilador.CompileAssemblyFromSource(parametros,codigo);<br />
The class made has inset classes of custom stringconverter for asssig enums to properyies and show in combo way.
<br />
this.Objeto = ensambaldo.CreateInstance("miNamespace.miClase",false,BindingFlags.CreateInstance,null,new object[]{this.DS.Tables[0].Rows[0]},System.Globalization.CultureInfo.CurrentCulture,null);<br />
Then I copy the code and paste to a fisical class.cs and compile the project and make an instance of myClass
I show the objects int PropertyGrid These objets
The object that made dianmically not show the combo feature in the properties but in the object made with the fisical file show the properties with the combo - enum feature, this one works fine.
What diferense can be have the two ways of make an object,
This is the Class:
<br />
<br />
using System;<br />
using System.Data;<br />
using System.ComponentModel;<br />
using System.Reflection;<br />
<br />
namespace miNamespace <br />
{<br />
public class miClase <br />
{<br />
<br />
private System.Data.DataRow m_Row = null;<br />
public static string[] Table1s = new string[4];<br />
public System.Collections.Hashtable ColCustomerID = new System.Collections.Hashtable();<br />
public System.Collections.Hashtable _ColCustomerID = new System.Collections.Hashtable();<br />
public static string[] Table2s = new string[9];<br />
public System.Collections.Hashtable ColEmployeeID = new System.Collections.Hashtable();<br />
public System.Collections.Hashtable _ColEmployeeID = new System.Collections.Hashtable();<br />
public miClase(System.Data.DataRow row)<br />
{<br />
m_Row = row;<br />
<br />
Table1s[0] = "Alfreds Futterkiste";<br />
ColCustomerID.Add("ALFKI","Alfreds Futterkiste");<br />
_ColCustomerID.Add("Alfreds Futterkiste","ALFKI");<br />
Table1s[1] = "Ana Trujillo Emparedados y helados";<br />
ColCustomerID.Add("ANATR","Ana Trujillo Emparedados y helados");<br />
_ColCustomerID.Add("Ana Trujillo Emparedados y helados","ANATR");<br />
Table1s[2] = "Antonio Moreno Taquería";<br />
ColCustomerID.Add("ANTON","Antonio Moreno Taquería");<br />
_ColCustomerID.Add("Antonio Moreno Taquería","ANTON");<br />
Table1s[3] = "Around the Horn";<br />
ColCustomerID.Add("AROUT","Around the Horn");<br />
_ColCustomerID.Add("Around the Horn","AROUT");<br />
<br />
Table2s[0] = "Davolio, Nancy";<br />
ColEmployeeID.Add("1","Davolio, Nancy");<br />
_ColEmployeeID.Add("Davolio, Nancy","1");<br />
Table2s[1] = "Fuller, Andrew";<br />
ColEmployeeID.Add("2","Fuller, Andrew");<br />
_ColEmployeeID.Add("Fuller, Andrew","2");<br />
Table2s[2] = "Leverling, Janet";<br />
ColEmployeeID.Add("3","Leverling, Janet");<br />
_ColEmployeeID.Add("Leverling, Janet","3");<br />
Table2s[3] = "Peacock, Margaret";<br />
ColEmployeeID.Add("4","Peacock, Margaret");<br />
_ColEmployeeID.Add("Peacock, Margaret","4");<br />
Table2s[4] = "Buchanan, Steven";<br />
ColEmployeeID.Add("5","Buchanan, Steven");<br />
_ColEmployeeID.Add("Buchanan, Steven","5");<br />
Table2s[5] = "Suyama, Michael";<br />
ColEmployeeID.Add("6","Suyama, Michael");<br />
_ColEmployeeID.Add("Suyama, Michael","6");<br />
Table2s[6] = "King, Robert";<br />
ColEmployeeID.Add("7","King, Robert");<br />
_ColEmployeeID.Add("King, Robert","7");<br />
Table2s[7] = "Callahan, Laura";<br />
ColEmployeeID.Add("8","Callahan, Laura");<br />
_ColEmployeeID.Add("Callahan, Laura","8");<br />
Table2s[8] = "Dodsworth, Anne";<br />
ColEmployeeID.Add("9","Dodsworth, Anne");<br />
_ColEmployeeID.Add("Dodsworth, Anne","9");<br />
<br />
if(row["OrderID"] != DBNull.Value)<br />
{<br />
this.OrderID = (System.Int32)row["OrderID"];<br />
}<br />
if(row["CustomerID"] != DBNull.Value)<br />
{<br />
if(ColCustomerID[row["CustomerID"]] != null)<br />
{<br />
this.CompanyName = (string)ColCustomerID[row["CustomerID"]];<br />
}<br />
}<br />
if(row["EmployeeID"] != DBNull.Value)<br />
{<br />
if(ColEmployeeID[row["EmployeeID"]] != null)<br />
{<br />
this.Name = (string)ColEmployeeID[row["EmployeeID"]];<br />
}<br />
}<br />
if(row["OrderDate"] != DBNull.Value)<br />
{<br />
this.OrderDate = (System.DateTime)row["OrderDate"];<br />
}<br />
if(row["RequiredDate"] != DBNull.Value)<br />
{<br />
this.RequiredDate = (System.DateTime)row["RequiredDate"];<br />
}<br />
if(row["ShippedDate"] != DBNull.Value)<br />
{<br />
this.ShippedDate = (System.DateTime)row["ShippedDate"];<br />
}<br />
if(row["ShipVia"] != DBNull.Value)<br />
{<br />
this.ShipVia = (System.Int32)row["ShipVia"];<br />
}<br />
if(row["Freight"] != DBNull.Value)<br />
{<br />
this.Freight = (System.Decimal)row["Freight"];<br />
}<br />
if(row["ShipName"] != DBNull.Value)<br />
{<br />
this.ShipName = (System.String)row["ShipName"];<br />
}<br />
if(row["ShipAddress"] != DBNull.Value)<br />
{<br />
this.ShipAddress = (System.String)row["ShipAddress"];<br />
}<br />
if(row["ShipCity"] != DBNull.Value)<br />
{<br />
this.ShipCity = (System.String)row["ShipCity"];<br />
}<br />
if(row["ShipRegion"] != DBNull.Value)<br />
{<br />
this.ShipRegion = (System.String)row["ShipRegion"];<br />
}<br />
if(row["ShipPostalCode"] != DBNull.Value)<br />
{<br />
this.ShipPostalCode = (System.String)row["ShipPostalCode"];<br />
}<br />
if(row["ShipCountry"] != DBNull.Value)<br />
{<br />
this.ShipCountry = (System.String)row["ShipCountry"];<br />
}<br />
}<br />
private System.Int32 m_OrderID;<br />
<br />
public System.Int32 OrderID<br />
{<br />
get { return m_OrderID; }<br />
set <br />
{ <br />
m_OrderID = value;m_Row["OrderID"] = value;<br />
}<br />
}<br />
<br />
private string m_CompanyName;<br />
[Browsable(true)][TypeConverter(typeof(Table1Converter))]<br />
public string CompanyName<br />
{<br />
get { return m_CompanyName; }<br />
set <br />
{ <br />
m_CompanyName = value;m_Row["CustomerID"] = _ColCustomerID[value];<br />
}<br />
}<br />
<br />
private string m_Name;<br />
[Browsable(true)][TypeConverter(typeof(Table2Converter))]<br />
public string Name<br />
{<br />
get { return m_Name; }<br />
set <br />
{ <br />
m_Name = value;m_Row["EmployeeID"] = _ColEmployeeID[value];<br />
}<br />
}<br />
<br />
private System.DateTime m_OrderDate;<br />
<br />
public System.DateTime OrderDate<br />
{<br />
get { return m_OrderDate; }<br />
set <br />
{ <br />
m_OrderDate = value;m_Row["OrderDate"] = value;<br />
}<br />
}<br />
<br />
private System.DateTime m_RequiredDate;<br />
<br />
public System.DateTime RequiredDate<br />
{<br />
get { return m_RequiredDate; }<br />
set <br />
{ <br />
m_RequiredDate = value;m_Row["RequiredDate"] = value;<br />
}<br />
}<br />
<br />
private System.DateTime m_ShippedDate;<br />
<br />
public System.DateTime ShippedDate<br />
{<br />
get { return m_ShippedDate; }<br />
set <br />
{ <br />
m_ShippedDate = value;m_Row["ShippedDate"] = value;<br />
}<br />
}<br />
<br />
private System.Int32 m_ShipVia;<br />
<br />
public System.Int32 ShipVia<br />
{<br />
get { return m_ShipVia; }<br />
set <br />
{ <br />
m_ShipVia = value;m_Row["ShipVia"] = value;<br />
}<br />
}<br />
<br />
private System.Decimal m_Freight;<br />
<br />
public System.Decimal Freight<br />
{<br />
get { return m_Freight; }<br />
set <br />
{ <br />
m_Freight = value;m_Row["Freight"] = value;<br />
}<br />
}<br />
<br />
private System.String m_ShipName;<br />
<br />
public System.String ShipName<br />
{<br />
get { return m_ShipName; }<br />
set <br />
{ <br />
m_ShipName = value;m_Row["ShipName"] = value;<br />
}<br />
}<br />
<br />
private System.String m_ShipAddress;<br />
<br />
public System.String ShipAddress<br />
{<br />
get { return m_ShipAddress; }<br />
set <br />
{ <br />
m_ShipAddress = value;m_Row["ShipAddress"] = value;<br />
}<br />
}<br />
<br />
private System.String m_ShipCity;<br />
<br />
public System.String ShipCity<br />
{<br />
get { return m_ShipCity; }<br />
set <br />
{ <br />
m_ShipCity = value;m_Row["ShipCity"] = value;<br />
}<br />
}<br />
<br />
private System.String m_ShipRegion;<br />
<br />
public System.String ShipRegion<br />
{<br />
get { return m_ShipRegion; }<br />
set <br />
{ <br />
m_ShipRegion = value;m_Row["ShipRegion"] = value;<br />
}<br />
}<br />
<br />
private System.String m_ShipPostalCode;<br />
<br />
public System.String ShipPostalCode<br />
{<br />
get { return m_ShipPostalCode; }<br />
set <br />
{ <br />
m_ShipPostalCode = value;m_Row["ShipPostalCode"] = value;<br />
}<br />
}<br />
<br />
private System.String m_ShipCountry;<br />
<br />
public System.String ShipCountry<br />
{<br />
get { return m_ShipCountry; }<br />
set <br />
{ <br />
m_ShipCountry = value;m_Row["ShipCountry"] = value;<br />
}<br />
}<br />
<br />
<br />
public class Table1Converter : StringConverter<br />
{<br />
<br />
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)<br />
{<br />
return true;<br />
}<br />
<br />
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)<br />
{<br />
return true;<br />
}<br />
<br />
public override<br />
System.ComponentModel.TypeConverter.StandardValuesCollection<br />
GetStandardValues(ITypeDescriptorContext context)<br />
{<br />
return new StandardValuesCollection(Table1s);<br />
}<br />
<br />
}<br />
<br />
public class Table2Converter : StringConverter<br />
{<br />
<br />
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)<br />
{<br />
return true;<br />
}<br />
<br />
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)<br />
{<br />
return true;<br />
}<br />
<br />
public override<br />
System.ComponentModel.TypeConverter.StandardValuesCollection<br />
GetStandardValues(ITypeDescriptorContext context)<br />
{<br />
return new StandardValuesCollection(Table2s);<br />
}<br />
<br />
}<br />
}}<br />
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|
I have some problem is C# -- in my program :
I will do transperment for label -- ???
i'am add picture to main form and in this picture i draw or write
some statement .. i want to coverd by trans. label ...???
Can You Help Me .... Please !!!
|
|
|
|
|
Umm... I don't really understand what you are trying to tell me here. Can u try and explain a bit more detailed?
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
in simple statement :
I want Diaphanousness or Limpidness or Pellucid or Transparence label
|
|
|
|
|
Well, if all you want is a transparent label, you can set its background property to Transparent, either through the IDE or programmatically.
Hope this helps
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
Hi,
I execute a command from inside my C# program. So the cmd window comes up when the processing realted to the command window is in execution.
How do I hide the window programmatically?
Here is what i do to execute the command from within the code.....
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo = new System.Diagnostics.ProcessStartInfo(command, commandLineArg);
process.Start();
Pls reply asap!
Thanks,
Sheela
|
|
|
|
|
I have not tried this, but...
There are StandardError , StandardInput and StandardOutput streams properties on a Process . If you were to assign your own streams to those properties, it should/could/may cause the window to not display.
my blog
|
|
|
|
|
In your ProcessStartInfo object, try setting the WindowStyle property to Hidden before you start your process.
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo = new System.Diagnostics.ProcessStartInfo(command, commandLineArg);
process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
process.Start();
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
This helped... thanks!
|
|
|
|
|
My English is not good.. if you can't understand,sorry..
I want to change value in resource of c# windows application from other application.
if my application is c++, I can use UpdateResource() of win32API.
But my application is c#. What do i have to do??
Please help me!!!!!
|
|
|
|
|
Hi, I have 2 questions:
1) I have a string with a full path to a file and I want to open a folder the file is in.
2) I have a system tray icon, when I right-click it i can choose to close the app or to show the full window. How do I do it so double click opens the window too?
Thanks for any answers!
|
|
|
|
|
Anonymous wrote:
1) I have a string with a full path to a file and I want to open a folder the file is in.
I am not sure about this one. A google search should give u the answer relatively easy.
Anonymous wrote:
2) I have a system tray icon, when I right-click it i can choose to close the app or to show the full window. How do I do it so double click opens the window too?
U have to handle the double-click event for the notify icon. Within this event you could say something like:
this.Show();
WindowState = FormWindowState.Normal;
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
Hi!
1) You can simply call Process.Start("explorer.exe", pathToShow); .
2) The NotifyIcon does have a DoubleClick event, according to the documentation.
Regards,
mav
|
|
|
|
|