|
Use ContextMenu class.
जय हिंद
|
|
|
|
|
Hello ,
Can anyone help me...?
I want to know As Applications (Ms Word, Excel, Photoshop,..etc) can open files in two ways:
either using OpenFileDialg-like dialog,
or by opening them when user in a file manager double clicks a file (that the application knows how to open - MsWord opens files with "doc" extensions, Photoshop opens "psd",... etc).
I have created an application using c# .Net (Windows Application).
I want MY APPLICATION to be able to open file in this way: that is without using [open file dialog].
I managed to "associate" particular file extension (let it be "abc") to be opened by my application,
when the file (with "abc" extension) is clicked the program starts - but I dont know how to get the full path to the file in order to open it.
So, currently the program is executed upon double-click - but the program does not open the file clicked.
I know how to open the file, but I must know which file to open. This is the problem.
I would expect also an event that would be fired if the program would be already running, and a file (with "abc" extension would be clicked in windows explorer
(or any other file manager)) .
Thanx n Regds
Kapil
|
|
|
|
|
You have to parse the command line arguments. For WinForms it is in Program.cs file. Initially your main function must be something like that:
static void Main()
{
Application.EnableVisualStyles();
Application.EnableRTLMirroring();
Application.Run(new Form1());
}
You have to change this method, to parse the command line arguments, because when you double click a file that is associated with your program windows basically sends the file name as an argument. For example:
myapp.exe C:\myfile.txt
Your main function must be changed to something like that:
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.EnableRTLMirroring();
if(args.length > 0)
{
Form1 frm = new Form1();
System.IO.StreamReader myFile = new System.IO.StreamReader(args[0]);
string line = "";
line = myFile.ReadToEnd();
frm.textBox1.Text = line;
myFile.Close();
Application.Run(frm);
}
else
Application.Run(new Form1());
}
The above code is just an example which reads a text file or one with an extension that you want to use into textBox1.
I hope this example helps you to solve your problem.
Nuri
|
|
|
|
|
Thank you very much Nuri.....
It really worked.
Thank you very very much...
|
|
|
|
|
How to blink label in C#.Please let me know the solution
thanks in advance
|
|
|
|
|
Use Timer with small time duration. Toggle the visibility of the label in the Tick event.
जय हिंद
|
|
|
|
|
d@nish wrote: Use Timer with small time duration. Toggle the visibility of the label in the Tick event.
...but don't do it unless it is realy important because you will annoy the heck out of your users.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Blink means Visible and False in a Interval.
If you can think then I Can.
|
|
|
|
|
Use Timer object and set label fore color different from its orignal and then set it orignal color,it will look like blinkin..
|
|
|
|
|
Hello,
I have a main form with a button that opens another form. But after it open it i can't return to the main form without closing this form. What do i need to write so i could return to the main form without closing the second form?
BTW - How, where and why do i need to do the form dispose?
|
|
|
|
|
Use Show() instead of ShowDialog() .
जय हिंद
|
|
|
|
|
OK. I will use form2.show();
When i close this form and want to open it again it writes an error exception says: "Cannot access a disposed object. Object name: 'Form2'."
What do i need to do to make it work?
|
|
|
|
|
Can you post the code how you are doing this?
May be you are using a class level object for Form2 and calling Show method in button click event. You need to create object in the click event itself. Like this:
private void button1_Click(object sender, EventArgs e)
{
Form2 o = new Form2();
o.Show();
}
जय हिंद
|
|
|
|
|
Ok,
I wrote before the "Form2 form2 = new form2();" not in the method of opening the form (button method) but outside in the class .
If i write it in the method it works but the problem is when i click the button of this form opening couple of times it opens again and again this form2 (i have many form2 opened).
I thought to use "if..." to check if form2 is already open and this way it won't open it again and again.
But maybe there is another way to prevent it?
|
|
|
|
|
Use Application.OpenForms property to check if the form is already opened. If it already open, just bring that to front and set focus.
जय हिंद
|
|
|
|
|
Another question-
If i write the new form2 in a method (of the button to open this form),
how can i use form2 in another method- for example a method that will check if this form2 is already open? Because in the other method it doesn't see the declaration of form2.
|
|
|
|
|
Application.OpenForms will work in any method.
जय हिंद
|
|
|
|
|
hi all
i am developing windows application in c#.net.i am using Socket concept in that.i have used one datagrid . using socket i filled up my data in grid and also i m using timer to update data in some columns of the data grid
now my problem is when i click on to the column of grid and try to wite in that column textbox i get the error for cross-thread invalidoperation
can anybody help into this problem
thanks in advance
|
|
|
|
|
Hi,
use delegate to refresh your data.
cheers,
Elie.
dghdfghdfghdfghdgh
|
|
|
|
|
hi Elie
thanks for solution but
is there any other way of it?
just because i m refresing the data thru the function inclass and that function i called thruout the application
|
|
|
|
|
that function should be called from a delegate
so create the delegate in ur class and call it.
Elie.
dghdfghdfghdfghdgh
|
|
|
|
|
Ankit At Codeproject wrote: now my problem is when i click on to the column of grid and try to wite in that column textbox i get the error for cross-thread invalidoperation
Which thread created the datagrid? What timer are you using, System.Windows.Forms.Timer or one of the other ones?
|
|
|
|
|
GUI components can only be modified from the thread that created them. As Elie said, you need to create a delegate for the function that modifies your datagrid, and then Invoke it on the GUI thread. Normally I do it like so, although there's probably a better way to do it:
delegate ReturnType DelegateType(T1 arg1, T2 arg2);
DelegateType del = YourMethod;
ReturnType YourMethod(T1 arg1, T2 arg2)
{
if(InvokeRequired)
{
return Invoke(yourDelegate, new object[]{arg1, arg2});
}
else
{
return someValue
}
}
For more info, check out the MSDN Documention for Control.Invoke[^].
Dybs
|
|
|
|
|
Hello,
i've an application that use a commandbuilder and a dataset and a datarow for inserting a new record in the database,but while i am trying to insert Arabic values they appear like ????
is their any solution or should i use the insert statement with a prefix N before values.
my code look like this :
SqlConnection myConn = new SqlConnection(SqlManager.Instance.ConnectionString);
SqlDataAdapter myAdapter = new SqlDataAdapter();
myAdapter.SelectCommand = new SqlCommand("select * from Exceptions", myConn);
SqlCommandBuilder custCB = new SqlCommandBuilder(myAdapter);
myConn.Open();
DataSet myDataSet = new DataSet();
myAdapter.Fill(myDataSet);
DataRow dr = myDataSet.Tables[0].NewRow();
string b = "شسيس";
dr[1] = b;
myDataSet.Tables[0].Rows.Add(dr);
myAdapter.Update(myDataSet);
myConn.Close();
dghdfghdfghdfghdgh
|
|
|
|
|
Check these links: this[^] and this[^]. Might help you.
जय हिंद
|
|
|
|