|
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
|
|
|
|
|
Currently I'm creating a c# app to extract data from a vendor specific text file and export it to an Access database.
OK, so I've created a DataSet with a DataTable in it, extracted the data from the file into the DataTable and now I'm trying to squirt this data into a table in the target database using a DataAdapter.
The target table has one key field defined within it.
If the table is empty all works as it should do, however if there is data already in the table the DataAdapter attempts to use an Insert command to update the data (when I think it should be issuing an Update command) and throws an error saying it would create duplicate keys.
And so the question.....
What method does the DataAdapter use to determine if the record being updated is new or changed? Does it look only at the key fields? or all fields?
Yours Despairingly
Simon
|
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
public struct JOB_INFO_1
{
public long JobId;
[MarshalAs(UnmanagedType.LPTStr)]public string pPrinterName;
[MarshalAs(UnmanagedType.LPTStr)]public string pMachineName;
[MarshalAs(UnmanagedType.LPTStr)]public string pUserName;
[MarshalAs(UnmanagedType.LPTStr)]public string pDocument;
[MarshalAs(UnmanagedType.LPTStr)]public string pDatatype;
//public string pStatus;
[MarshalAs(UnmanagedType.LPTStr)] public string pStatus;
public long Status;
public long Priority;
public long Position;
public long TotalPages;
public long PagesPrinted;
public SYSTEMTIME Submitted;
}
[StructLayout(LayoutKind.Sequential)]
public struct SYSTEMTIME
{
public int wYear;
public int wMonth;
public int wDayOfWeek;
public int wDay;
public int wHour;
public int wMinute;
public int wSecond;
public int wMilliseconds;
}
[DllImport("winspool.drv", CharSet=CharSet.Auto)]
public static extern bool OpenPrinter( string pPrinterName, out IntPtr
phPrinter, IntPtr pDefault );
[DllImport("winspool.drv", CharSet=CharSet.Auto)]
public static extern bool ClosePrinter( IntPtr hPrinter);// handle to printer
[DllImport("winspool.drv", CharSet=CharSet.Auto)]
public static extern int EnumJobs( IntPtr hPrinter, int FirstJob, int
NoJobs, int Level, IntPtr pInfo, int cdBuf, out int pcbNeeded, out int
pcReturned);
[SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.UnmanagedCode)]
public void JobsInPrinter(string Printer)
{
IntPtr handle;
int FromJob = 0;
int ToJobs = 100;
int pcbNeeded;
int pcReturned;
// open printer
OpenPrinter (Printer, out handle, IntPtr.Zero );
// get num bytes required
EnumJobs ( handle, FromJob, ToJobs, 1, IntPtr.Zero, 0, out pcbNeeded, out pcReturned);
if(pcbNeeded > 0)
{
// allocate unmanaged memory
IntPtr pData = Marshal.AllocHGlobal ( pcbNeeded );
// get structs
EnumJobs ( handle, FromJob,ToJobs, 1, pData, pcbNeeded, out pcbNeeded, out pcReturned);
// create array of managed job structs
JOB_INFO_1 [] jobs = new JOB_INFO_1[pcReturned];
// marshal struct to managed
int pTemp = pData.ToInt32(); //start pointer
for (int i=0; i
|
|
|
|
|
I am trying to figure out the best way to pass connection information to a spawned thread after accepting a socket connection. I know that the listener information is perishable and I want to eliminate the risk of losing the connection information. Here is what I am doing.
connection = listener.AcceptSocket();
Thread connThread = new ThreadStart(MsgManager));
connThread.Start();
Now I want MsgManager to have access to "connection"
Can someone tell me the accepted practice (if there is one) for getting this connection information to the MsgManager?
Sorry if this is a really stupid question, but I am having a mental block here.
Thanks,
Bob Robey
|
|
|
|
|
If MsgManager is in the same class, you can simply make connection a member variable of that class. If not, the only way I know of is to wrap the Thread within another class (or derive from Thread) and pass connection as a parameter to the constructor of the wrapper.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I was afraid of that. I just thought someone would have some nifty trick. Thanks for your response.
Regards,
Bob Robey
|
|
|
|
|
I have a little problem
I got a form with a lot off buttons.
i use this code to get the Text of the button i pushed:
string naam,naam2;
naam=sender.ToString();
naam2=naam.Substring(35);
textBox1.Text=naam2;
But the problem is i want to change the color of that button as well.
Could someone tell me how i can determin witch button i pussed with appling just one piece of code to all the buttons?
|
|
|
|
|
Have a common (i.e., the same) event-handler for all the buttons on your form, say ButtonClick. Implement this common event-handler as under, for example:
private void ButtonClick(object sender, System.EventArgs e)
{
if((Button)sender == button1)
{
button1.BackColor = Color.Green;
MessageBox.Show("button1 was clicked", "Form1");
}
else if((Button)sender == button2)
{
button2.BackColor = Color.Pink;
MessageBox.Show("button2 was clicked", "Form1");
}
else if((Button)sender == button3)
{
button3.BackColor = Color.Blue;
MessageBox.Show("button3 was clicked", "Form1");
}
else if((Button)sender == button4)
{
button4.BackColor = Color.Yellow;
MessageBox.Show("button4 was clicked", "Form1");
}
}
It works properly and identifies the correct button pressed. You can add your own code in place of the sample code above. If the number of buttons is too large, you can even consider having an ArrayList of the buttons.
|
|
|
|
|
Hello
you don't have to declare 2 string variables here. Try:
textBox1.Text = sender.ToString().Substring(35);
As to get the button, have you tried:
Button myButton = (Button)sender;
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
The sender argument of your Click event handler _is_ the button that was pressed.
So you can easily cast it to Button and then do with it whatever you want:
private void button_Click(object sender, System.EventArgs e)
{
Button b = sender as Button;
if (b != null)
{
foreach (Control c in this.Controls)
{
if (c is Button)
c.BackColor = SystemColors.Control;
}
b.BackColor = Color.Red;
}
}
Regards,
mav
|
|
|
|
|
And no one has suggested it yet... but this might help:
Button btn = (Button) sender;
MessageBox.Show(btn.Text); I hope this helps!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Ok heres a question its roaming my mind.
Whats the difference doing for example.
SqlConnection con= new SqlConnection(connection_string);
con.close();
con.dispoe();
and
con= null;
AFAIK i think this. Close just clsoes the connection and can be opened again, dipose frees the resources so it cant be opened again, must declare again and null makes the GC get it faster. With this object i see it clearly but its the same for others?
DataSet ds= new DataSet();
Lets take about datasets, if i do a ds.dispose() its completely erased? and what about if i do ds=null; whats will do if i return the dataset in a method and later i do a dispose or a null in the finally clausule.
Ty for ur time.
|
|
|
|
|
Not really. SqlConnection's Close and Dispose do the same thing, if you look at the code, Dispose calls Close. null doesn't necessarily make the GC get it faster, in general, the GC is intelligent enough to figure out that that object has no live references. The only place where setting to null is recommended is if that object is contained within a long living object.
So the answer is
1. Close and Dispose do the same thing. It has nothing to do with GC.
2. Setting to null doesn't make the GC get it faster in most cases.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
The previous post is not entirely correct. Close() and Dispose() do not do the same thing with respect to a SqlConnection. It is true that Dispose() will close the connection if the ConnectionState is Open, but the converse is not true: if Close() is called, the SqlConnection is not disposed, and your initial assertion is correct - the connection may be re-opened.
In general, the following should ideally be true for disposable types (the concept of Close is not covered, since it doesn't really apply to the discussion, and may mean different things to different types - file streams, database connections, sockets etc.):
1. Dispose() should be responsible for cleaning up unmanaged resources and indicating to the GC that finalization is suppressed for the instance (suppressing finalization explicitly avoids the default two-pass collection of collectible objects). The value of Dispose() is that unmanaged resources can be reclaimed immediately (or nearly so), without waiting for the GC. Suppressing finalization for the object serves to streamline the garbage collection process so that it takes only one pass to reclaim the managed resources used by the object instead of two passes (one to finalize, one to reclaim).
2. Setting an object to null just drops a reference to the object, essentially setting it adrift in the (managed) heap until the GC executes and begins cleaning it up. There is no guarantee about when the resources for that object will be reclaimed.
For more info, look here.[^]
Hope this helps.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
turbochimp wrote:
It is true that Dispose() will close the connection if the ConnectionState is Open, but the converse is not true: if Close() is called, the SqlConnection is not disposed
I don't understand. If Dispose calls Close(), then Dispose and Close must do the same thing. What do you mean by "the SqlConnection is not disposed" ? If you can call Open() on a connection on which you've called Close, you can as well call it after calling Dispose(). Dispose doesn't do anything extra, as you can see with a tool like Reflector.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|