|
|
Argh - yes. However, that returns the user that is running the current process, not a specific process from the processes list. I suppose, thinking about it, it's probably the same thing under Windows 98, as there are no services so presumably no "system" users, and no fast user switching, so all processes must be run by the same user.
Also, I had very odd results with Environment.UserName - if I didn't set up any users on a new W98 installation then Environment.UserName returned "User" which must be some sort of default. However, I then set up a real user. Then, when I logged in, I hit Cancel on the login dialogue. Now, strangely, Environment.UserName returns blank. Go figure, as they say. I suppose W98 just doesn't handle users properly and there it is.
Nevertheless, thanks for getting back to me.
Dave
|
|
|
|
|
How to find file in hard disk?
|
|
|
|
|
Directory.GetFiles(directoryToSearch, fileName) where fileName can include wildcards
Ed
|
|
|
|
|
I have a simple application that takes a folder path and open in the windows explorer.
Here is the code i use
Process p = new Process();
p.StartInfo.FileName = "explorer.exe";
p.StartInfo.Arguments = strFilePath;
p.Start();
The problem is that when the filepath contains spaces it works just fine on my xp machine but on my clients machine which use windows 2000 the application fthrows the exception filenotfound.
I would like to know why it works on xp and doesn't on windows 2000
|
|
|
|
|
try by this
...
p.StartInfo.FileName = "iexplorer.exe";
...
_____________________
Proud to be Albanian
_____________________
|
|
|
|
|
Have you tried wrapping the path with embedded quotes.
"\"path with spaces\myapp.exe\""
-- modified at 11:04 Thursday 16th March, 2006
More generally, paste the exact string you send to the process class into the run dialog and see what happens there.
|
|
|
|
|
hi,
i am using DrawString method to display text in my Smartphone application when form is painted. i have added a method to the Paint event handler for this:
this.Paint += new PaintEventHandler(DrawMainPage);
when i get new data i have to repaint the form to inorder to show new data.
but when i call myform.invalidate() from different form then i gives me error that i have to invoke this method from the same thread.
i tried do upate my code accordingly (http://www.codeproject.com/csharp/begininvoke.asp)
but i get the same error.
will appreciate help.
regards,
rnv
|
|
|
|
|
Try making sure that you're Main function is marked with a STAThread attribute. If you're not using any multithreading that it
Ed
|
|
|
|
|
i would like to know how to read an image with c#
if u can give me a code in witch there are an example
developpement
|
|
|
|
|
Do you mean this?
Divyang Mithaiwala
System Engineer & Software Developer
|
|
|
|
|
You can use this code:
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
{<br />
Graphisc g = e.Graphisc;<br />
Bitmap bmp = new Bitmap("your_image.jpg");<br />
g.DrawImage(bmp, 0, 0);<br />
}
-- modified at 9:27 Thursday 16th March, 2006
|
|
|
|
|
Except that it will leak resources. The Bitmap reading code should ideally read to a member variable ( why do it every time ? ), or at a minimum, should be in a 'using' block.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I have a Deployment project which includes a Customer Information Dialog box. I want to use the information entered in my Custom Action class AfterInstall. Does anyone know how I can do this?
|
|
|
|
|
Can any one guide me how to launch the installed application immediatley after the Finished screen button clicked. Once the user clicks the finished screen "Close" button, i need to launch the installed application. I tried with installer class. Sample code is given below.I have created a class library and within that an installer class. I tried with the afterInstall event, but its not working.
namespace ClassLibrary1
{
[RunInstaller(true)]
public partial class Installer1 : Installer
{
public event InstallEventHandler AfterInstall;
public Installer1()
{
InitializeComponent();
AfterInstall += new InstallEventHandler(AfterInstallEventHandler);
}
private void AfterInstallEventHandler(object sender, InstallEventArgs e)
{
Process.Start(@"C:\Program Files\Surisoft\SampleSetup\SampleApplication.exe", "/q");
}
}
}
Regards
Mukilan.P.S
|
|
|
|
|
i have two form: Form1, Form2 and Form3. Form1 is MDI Parent form. i'v made Form2 to open when one menu is clicked from Form1. Now Form2 has one button which should show Form3, and i'v done the code this way:
Form3 frmF3 = new Form3();<br />
Form1 fm1 = new Form1();<br />
<br />
frmF3.MdiParent = fm1;<br />
frmF3.Show();
but clicking the button is performing nothing. how can i do that?
|
|
|
|
|
Dear,
Try to structure your code by doing the following:
-In form3 add the following Function:
public void Create(Form ParentWnd)
{
MdiParent = ParentWnd; Show();
}
- Now from Form2 do the follwing from a function of course:
Form3 form3 = new Form3();
Form ParentForm = this.MdiParent;
form3.Create(ParentForm);
I've been programming since year 1999, graduated from Univeristy Paris 2 France, fluent in C,C++,VC++,Web programming (XML,HTML,php etc..),.NET frameworks,C# and ASP.NET,SQL server, Mastering VC++ .NET and SQL server,data structure and database design
|
|
|
|
|
thanx for ur help
i did this way
Form3 frmF3 = new Form3();<br />
<br />
frmF3.MdiParent = this.MdiParent;<br />
frmF3.Show();
it worked. thanx again.
|
|
|
|
|
Hi there
can someone please help me?
I want to select a row from form1 and then open another form (form2) which shows the same row but with some more fields...
so..
form 1. datagrid about 4 collums from the database table. then dubbel click on it
form 2. a couple of textfields.. (about 10) which shows all the records in the row.
i use C# winforms.
i've tried a lot of thinks but it just won't work....
|
|
|
|
|
Moddify the constructor of form2 so that it takes the ID of the row and then display the information you need.
On form1 make a event hanlder that will respond to the doubleclick on the datagrid and then make a new form in that event handler that will pass the id of the row to the form2.
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
but how?
i actualy got al the coding.. but it just don't work.. and i really dont know why.
public void dataGrid_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
int rowIndex = dataGrid1.CurrentRowIndex;<br />
if (CustomRow != null)<br />
{<br />
CustomRow(this, new CustomRowEventArgs(barry11,dataGrid1,rowIndex));<br />
}<br />
<br />
}
public class CustomRowEventArgs : EventArgs<br />
{<br />
<br />
public Barry1 DaSet;<br />
DataGrid grid;<br />
int row;<br />
<br />
public CustomRowEventArgs(Barry1 DSet,DataGrid Grid,int Row)<br />
{<br />
DaSet = DSet;<br />
grid = Grid;<br />
row = Row;<br />
<br />
}<br />
public Barry1 DSet<br />
{<br />
get { return DaSet; }<br />
}<br />
public DataGrid Grid<br />
{<br />
get { return grid; }<br />
}<br />
public int Row<br />
{<br />
get { return row; }<br />
}
that DaSet.. should be barry11 (my dataset) DaSet was kinne like a test or something..
or what variable or class or something should i put there..
public virtual void customHandler_CustomRow(object sender, CustomRowEventArgs e)<br />
{<br />
Barry1 DaSet = e.DaSet;<br />
DataGrid dataGrid1 = e.Grid;<br />
int row = e.Row;<br />
<br />
textBox.Text = dataGrid1[e.Row,0].ToString();
this textbox stands on the same form so i could test it and see it quick if it works or not..
but it doesn't...
|
|
|
|
|
Quick'n dirty...
In the main form, when a row in the datagrid is double clicked:
<br />
private void dgInfo_DoubleClick(object sender, System.EventArgs e)<br />
{ <br />
Form2 frm=new Form2(ds, dgInfo.CurrentRowIndex);<br />
frm.ShowDialog();<br />
}<br />
In the constructor of Form2:
<br />
public Form2(DataSet ds, int index):this()<br />
{<br />
textBox1.Text=ds.Tables[0].Rows[index][0].ToString();<br />
textBox2.Text=ds.Tables[0].Rows[index][1].ToString();<br />
textBox3.Text=ds.Tables[0].Rows[index][2].ToString();<br />
}<br />
Helpful perhaps...
|
|
|
|
|
If I can help you, sure.
What do you want to know?
|
|
|
|
|
eh first of all the datagrid is on my form.
the and filled with data from my database.
my data set named "barry11"
which is the correct code to select a row from this grid.
second.
which code do i need te read the first field (firsname) into a textbox on the same form.
if that works i'm already pretty happy. to..
i was thinking.
can't I put the selectet row into a parameter and give this one to my second form. where my select query will be "SELECT * FROM BARRY WHERE FIRSTNAME == PARAM1:" Or something like that. just a theorie that i was thinking of.
-- modified at 10:28 Thursday 16th March, 2006
|
|
|
|
|
Rmokkenstorm wrote: my data set named "barry11"
which is the correct code to select a row from this grid.
First, find the index of the selected row in the datagrid by means of dataGridName.CurrentRowIndex. This rowindex corresponds to the index of the underlying dataset.
Rmokkenstorm wrote: second.
which code do i need te read the first field (firsname) into a textbox on the same form.
if that works i'm already pretty happy. to..
textBox2.Text=ds.Tables[0].Rows[index]["firstname"].ToString();
Work with the underlying dataset (ds above) instead of the datagrid.
Rmokkenstorm wrote: i was thinking.
can't I put the selectet row into a parameter and give this one to my second form. where my select query will be "SELECT * FROM BARRY WHERE FIRSTNAME == PARAM1:" Or something like that. just a theorie that i was thinking of.
Sure...
HTH
|
|
|
|