|
hi
This will display one child node names "fake node" , so after expanding it first i have to remove that first fake node it and then fill the actual child nodes. i am trying how to remove that node first but so far not able to do so.
In my application there are thousands of child nodes that i received from another machine. i do not want to store that data in memory so i will fetch that data only if user asks for it by expanding the node.
|
|
|
|
|
sandeepvilasjoshi wrote: so after expanding it first i have to remove that first fake node
Not so. The BeforeExpand event happens before the parent node is expanded at all. So in the handler you remove your fake node bfore the parent node would ever expand. Thus no user will ever see your fake node. Removing it would be easy by one line in the handler.
e.Node.Nodes[0].Remove();
Also I made two more suggestions in my previous post that would give an alternate way of doing it.
sandeepvilasjoshi wrote: i do not want to store that data in memory
Each tree node won't take more than few bytes long in memory. Most modern computers got memory of 256Mb or more. So if you want to go through all these trouble just to save 200-300 Kbs of memory -which is very trivial- you are absolutely wrong. The above method will make a major performance hit in your program -try it-. Unless you got a million or more nodes I wouldn't recommend your idea. After all it's still your choice. Try this, and that and profile -some sort of speed test- your application, then decide where to go.
Regards
|
|
|
|
|
Nader Elshehabi wrote: "user hostile"
I agree, in fact if you need to allow the user to add items the TreeView may not be the control to use. If you insist, then I suggest a context menu, with Add, Remove, Edit, etc.
Some times the envelope pushes back.
|
|
|
|
|
Could somebody give me a sample code of chart control?
|
|
|
|
|
|
Over 40 people already published one on CodeProject
Luc Pattyn
|
|
|
|
|
hi, i have a windows application. in load event of my form i retrieve data from " Microsoft Access" database.
when i build or run form,i see several Error MessageBox with this content : "object reference not set to an instance of an object ".
after that i submit these , Program Runs Successfully!!
what is my problem?
thanks
|
|
|
|
|
You somewhere access a variable that is set to null .
The debugger will show you which variable this is, just run the Debug build.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
How to get the file path on mouse right click in c#?
Thanks & Regards,
Venkat
|
|
|
|
|
Please search on msdn first .....
then search on google .....
followed by looking in the previous posts ......
If you still do not get answers, post a message here ...
Regards,
Bhupi Bhai.
|
|
|
|
|
I had posted this message only after searching in google and msdn..
I have a windows based application in c#. On Windows explorer context menu i added one context menu item named "MyContext" . when the user right clicks on a file or folder, i have "MyContext" menu(This is the context menu item that i have added to the windows explorer context menu). When i click "MyContext" menu, i have to execute one application. In that application page load, i want to get the file or folder path that the user right clicked.
How to get that file path?? Please help
-- modified at 5:19 Wednesday 3rd January, 2007
Thanks & Regards,
Venkat
|
|
|
|
|
What you are talking about is called Windows Shell programming -not context menu -. In CodeProject there is a very good section about Shell programming. i think you can find the anwer there. Click here[^].
Regards
|
|
|
|
|
I agree that this is windows shell programming. In that path is generated by args[0]. I have an application, which contains a tab control. inside the tabcontrol i am having a textbox. I am getting the string args[0] value from the program.cs file. I want to assign the string args[0] value to the textbox. How to assign that value to the textbox?
This is the program.cs file
static class Program
{
public static string pathkey;
public static string path
{
get
{
return pathkey;
}
set
{
pathkey = value;
}
}
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
Form1 objform = new Form1();
try
{
Program.pathkey= args[0].ToString ();
}
catch (Exception ex)
{
}
Form1.cs
*********
In my form1 load, i am assigning the value to the textbox
txtLocation.Text = Program.pathkey.ToString();
But i am not able to get the value?
In registry i have the entry as C:\Documents and Settings\venkadeshp\My Documents\Visual Studio 2005\Projects\HCI_DMS ConsoleApplication\bin\Debug\HCI_DMS ConsoleApplication.exe %1 . But i couldnt find the file path in the string args[0] in the program.cs main function?
Thanks & Regards,
Venkat
|
|
|
|
|
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
|
|
|
|