|
Venkatesh.P wrote: How to assign that value to the textbox?
Simple. In your Main method
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1(args[0]));
}
and in Modify your form constructor to this
Form1(string thePath)
{
MyFileName = thePath;
}
PS.
The first argument would be the path to your exe file BTW, and the second argument is the "%1" command which is used to instruct the program to open the file -not print it for example-. The Thrid argument -i.e. args[2]- I bilieve is what you are looking for. Try to show them one by one in MessageBox s ro see the value of each before deciding which to pass to the Form's constructor.
Regards
|
|
|
|
|
Well, I've found several INI Readers here, which helped, but they didn't solve my real problem.
My INI file I have (which I cannot change, I only read from it), has stuff like this:
[Section]<br />
Key=Value<br />
Key=Value2<br />
Key=Value3<br />
Key=Value4<br />
Key=Value5
etc... Same key, but 5 different values. Every INI Reader I've seen so far, will only read the first one.
Does anyone have any solution?
Secondly, In my dialog I have this listview, which I want to fill from a self-made method. The listview is simply called "listView1", but whenever I try to use that name in my method (i.e. listView1.Items.Add("Test");) I get this error:
An object reference is required for the nonstatic field, method, or property 'WindowsApplication1.Form1.listView1'
What do I need to do to make it work :p
|
|
|
|
|
(1) You have done you own version of INI file, so you have to make a reader for that...
(2) I don't know (maybe posting the code will help).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
(1) No, I haven't. As I specific earlier, the INI file is made by an external program (a game, to be specific).
(2) What code? the INI Reader I found?
|
|
|
|
|
(1) OK, my hypothesys was wrong, you didn't write that. Anyway, IMHO, you have to write a reader for such non-compliant INI file.
(2) That was referring to the listview trouble you experienced.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
(1) Well, any tips? :p
(2) errr.. I deleted it because I couldn't get it, but I used something like this (well it had more, but this suffices to prodouce the same error):
public static void LoadFavorites()<br />
{<br />
listView1.Add.Items("test");<br />
}
|
|
|
|
|
2) In case the method is static you cannot access instance variables.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
(1) The Windows API GetPrivateProfileSection loads a buffer will all section content (keys are NULL separated). I don't know if it will be of any help to you.
(2) Ok, let's forget about it...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
A) The only built-in way I know of to read an INI file is with the Windows API and P/Invoke:
<br />
[System.Runtime.InteropServices.DllImport ( "kernel32" , SetLastError=true , EntryPoint="GetPrivateProfileString" )]<br />
private unsafe static extern uint<br />
API_GetPrivateProfileString<br />
(<br />
string lpAppName <br />
,<br />
string lpKeyName <br />
,<br />
string lpDefault <br />
,<br />
byte* lpReturnedString <br />
,<br />
int nSize <br />
,<br />
string lpFileName<br />
) ;<br />
<br />
public unsafe static int<br />
GetPrivateProfileString<br />
(<br />
string lpAppName <br />
,<br />
string lpKeyName <br />
,<br />
string lpDefault <br />
,<br />
out string lpReturnedString <br />
,<br />
int nSize <br />
,<br />
string lpFileName<br />
)<br />
{<br />
int result ;<br />
byte[] temp = new byte [ nSize ] ;<br />
<br />
fixed ( byte* ptemp = temp )<br />
{<br />
result = (int) API_GetPrivateProfileString<br />
(<br />
lpAppName <br />
,<br />
lpKeyName <br />
,<br />
lpDefault <br />
,<br />
ptemp <br />
,<br />
nSize <br />
,<br />
lpFileName<br />
) ;<br />
}<br />
<br />
lpReturnedString = PIEBALD.Lib.LibStr.FromByteArray ( temp , true ).Substring ( 0 , result ) ;<br />
<br />
return ( result ) ;<br />
}<br />
B) You need to provide a reference to an instance to listView1.Items.Add(), the literal "Test" won't work.
|
|
|
|
|
Yeah I managed to fix no 2.
As for the first one, that still doesn't help...
What I need is something that can read INI Files using:
FileName, Secion Name, Key Name, and N.
N being the Nth matching key...
Any ideas?
|
|
|
|
|
how to access my outlook express from my application,sending mail ,checking mail...
ravi
|
|
|
|
|
Up to my knowledge, Outlook Express does not support automation by itself.
Therefore, you might find this link[^] useful.
SkyWalker
|
|
|
|
|
here we have to pay to download it..???
any other solution do u have...??pls suggest to me..
ravi
|
|
|
|
|
Not everything in the world is taken for free
SkyWalker
|
|
|
|
|
As regards sending mail from your application....
If you make it a web application - you've got the HTML "Mailto" - option.
- Or had you already considered that ...
|
|
|
|
|
Hi All,
Anyone know of any code tidy-up tools?
I want to group all my member declarations, all my properties, all my methods together, rather than the higgledy-piggledy mess they're in now.
Is there anything out there to help?
|
|
|
|
|
Nope, I don't think so.
It's just us who can take care of this .... manually :->
Regards,
Bhupi Bhai.
|
|
|
|
|
If you don't have time to do it right, when will you have time to do it over?
Or consider putting each in its own file?
|
|
|
|
|
hello to all friends ;
i need to use ipx connection in my (C#) project , but there is a problem , if any can help me with a little project (describing the use of ipx ) i will be grateful.
-- modified at 6:36 Wednesday 3rd January, 2007
|
|
|
|
|
Using .net 2.0
Is it possible to have a stored procedure with several select statements so that a dataset can be populated with all of the select statements. So the dataset will end up with several tables (One table for one select statement).
At present I use the dataadapter to fill the dataset. I do this for each stored procedure which holds a select statement each.
But rather than repeating this method several times (One for each select), I would like to do all this in one stored procedure and populate a dataset with the results of these tables.
Is this to do with MultipleResultSet (MRS)?
Any suggestions please?
Thanks
|
|
|
|
|
|
Shouldn't that work? Rather than a stored procedure simply have several selects in one statement?
CommandText="select blah blah blah ; select something else" ;
(With SQL server anyway, not all engines support it.)
|
|
|
|
|
Hi,
i am using a listBox that contains some items.
I tried using the double click event of the list box to make some action based on the item that is double clicked in the listBox.
But i discovered that also if i double click on the empty part of the listBox,(not on an item) the event is still fired.
I wish to know if there is a way to make sure that the event is only raised when only an item is double clicked.
thanks in advance
|
|
|
|
|
quiteSmart wrote: I tried using the double click event of the list box to make some action based on the item that is double clicked in the listBox.
But i discovered that also if i double click on the empty part of the listBox,(not on an item) the event is still fired.
You can programmatically distinguish between the two cases.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
CPallini wrote:
You can programmatically distinguish between the two cases.
How to do that?
|
|
|
|