|
Hi
{
I have to Generate an XML file from an existing XML.
The existing File is on HDD and and the Elements of the file are shown in a Tree view.
Now when the tree node is selected the child nodes are displayed in the checked List Box.
}Done
Now the selected chiled nodes along with its coressponging Paret node in tree view will be writen to another XML file.
Does any one have SAMPAL code for this task or can any one giude me.
Thanks.
Best Regards.
|
|
|
|
|
Is it possible to write code for selecting a folder and a file together from OpenFileDialog? The default operation appears only selection of a file.
|
|
|
|
|
Is it possible to change the name of the "Open" button in the OpenFileDialog class instance in C# application?
|
|
|
|
|
no because it is declared 'sealed' so you cannot inherit from it or modify it.
in the msdn library you can see this:
public sealed class OpenFileDialog : FileDialog
|
|
|
|
|
I did it once,:->
But that was because i created my own open file and open forlder dialog from the scratch.
|
|
|
|
|
It is possible but you have to use P/Invoke to create this dialog from scratch using the GetOpenFileName() call and the OPENFILENAME structure from the Win32 platform SDK on MSDN. In the OPENFILENAME structure specify a hook procedure for the lpfnHookProc data item. In this hook procedure capture the WM_INITDIALOG message, get the handle to the OK button, and call SetWindowText to change the name from "Open" to something else.
I hope this helps.
Human beings were not meant to sit in little cubicles staring at computer screens all day, filling out useless forms and listening to eight different bosses drone on about about mission statements. -- Peter Gibbons
|
|
|
|
|
Hi,
I want to update the value for a particular key in Hashtable.
How to update.
Usually in VB 6, i have used item property. But here i unable to use it
Thanks in Advance
Balamurugan
|
|
|
|
|
|
Hi,
I am a beginner level programmer and I would be happy
if somebody can clarify me this small doubt.
I want to know,if using 'this' to refer to the local variables inside a class is a good practice. using 'this' would be a bit costly or it would infact aid performance ?
Please clarify this , would be more thankful if you can give me some links for improving code performance.
Thanks a ton.
|
|
|
|
|
It doesn't make any difference. Whether you explicitly use "this" or not, the compiler generated code will have to use it to refer to member variables and methods.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
As far as I know, it doesn't hurt or boost the performance. It's rather a question of taste. Do you like the style of using 'this' for calling private variables ?
In my opinion it doesn't matter if you use 'this', but I prefer only using it when there's no other way. An example:
private int var;<br />
<br />
public SomeClass(int var) {<br />
this.var = var;<br />
}
WM.
What about weapons of mass-construction?
|
|
|
|
|
A local variable is one which is within the scope of the method or property, not the class. I think what you mean is member variable (aka field in .NET)
Using the this keyword is just making explicit what the compiler will do implicitly anyway. There is no perfomance advantage to using it or not as the resulting code will be compiled to be the same anyway.
The only time where it does make a difference is where you have a local variable and a member variable with the same name. You must use the this keyword to refer to the member variable in that instance otherwise the compiler will assume you are referring to the local variable.
Does this help?
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
There is no difference in the created IL code wether you use this or not.
(try Lutz Röders excelent Reflector tool to check this).
(field accesses will always resolve to a ldfld opcode and method calls to call or callvirt )
I personally changed my way of using the this keyword.
I started by not using it at all beeing happy not to have to use it as in the old c++ days...
Then i switched to use it on fields and properties. Simpy for readability.
Now i went as far as using it for method calls too.
Even though it seems a little overdone i think the code readability gains a lot.
Especially for everyone who has not written the code but is reading it.
By using the this keyword it is immediatly clear that you refere to a member of the current class.
Currrently i am not as far as using the base keyword for any derieved method.
As long as a method, field or property is not ambigious it is completely up to you and your personal style whether you use the this keyword or not.
/cadi
|
|
|
|
|
Also, using 'this' will give you intellisense to speed your typing, or just to let you browse for the item you are looking for.
|
|
|
|
|
I'm using a System.Timers.Timer to send some data to a serial port every so often. Problem is, if the main thread gets tied up, with internal processing, or hitting a breakpoint for example. A long queue of events gets queued up, then once the app is back in business, all of the messages get handled almost simultaniously. I've tried to come up with a work around, but I'm stumped, any suggestions.
Thanks,
sam
|
|
|
|
|
do not use a timer but use a thread.
Timers use the WM_TIMER message internally. If the message queue dispatching is deleayed (i.e. by some other messages that take a long time to process) a lot of WM_TIMER messages will be queued and then be dispatched all at once.
a thread function could look like this:
private ManualeResetEvent m_Done = new ManualeResetEvent(false);
private int m_Delay = 1000;
public void SendToPort()
{
while (true)
{
this.m_Port.Send(new byte[1]{1});
if (m_Done.WaitOne(this.Delay,false) )
break;
}
}
use the m_Done event to abort the loop.
/cadi
|
|
|
|
|
The OP is using System.Timers.Timer which does not depend on the application running a message pump. But yeah, your idea is right, a thread will solve the problem.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hey everybody.
sorry for the ignorence but I keep on having problems with this stuff.
I'm asking it in a general way, not specific to the app I'm building.
lets say I have 2 window forms, Main (form) and Modal (form).
the Main form has a memeber, lets say "m_strText" which is a public memeber.
now, from the Main form I'm opening the Modal form:
Modal dlgModal = new Modal();
dlgModal.ShowDialog();
at this moment of course the Modal form opens as a modal form.
the thing is that now I want to control the "m_strText" member from the Modal form.
as far as I know you do it like this:
Main dlgMain = new Main();
dlgMain.m_strText..... bla bla bla
but it won't work! because I created a new Main object, and I want to change the one that I am using...
how can I control my Main form without creating a new object?
Thanks!
p.s.
in my case it is a statusbar item that I want to change.
|
|
|
|
|
You just need to pass MainForm to the ModalForm, maybe as a constructor parameter. Like this
Modal dlgModal = new Modal(this);
dlgModal.ShowDialog();
Your Modal class will then look like this
class Modal : Form
{
Form parentForm;
public Modal(Form parentForm)
{
this.parentForm = parentForm;
}
}
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thank You!!!
|
|
|
|
|
Try using a third party in this one. A simple class that acts like a messenger between the two objects.
public delegate void MessagePostedEventHandler(object sender,string message);
public class Messenger {
public event MessagePostedEventHandler MessagePosted;
public void PostMessage(String message) {
if(MessagePosted != null) {
MessagePosted(this,message);
}
}
}
There are a few steps to be taken:
1. Create the messenger object
2. Register the MessagePosted event with the main object
3. Create the Modal object and pass the messenger object to the Modal object
4. Call PostMessage in the Messenger object in the Modal object
5. Handle the event in the main object (and change the statustext)
And viola, you have a perfectly working system that posts status messages
in the correct way without much more work
WM.
What about weapons of mass-construction?
|
|
|
|
|
i want reg exp for allow only Numeric value and only one decimal point
this is need for enter the price/rate..
ex- 1000.99,.09 (allow)
and not allowed for any other cherector ex- [ a32.%],100$,}
thanx in advace
uregent
|
|
|
|
|
Try this one:
^\d*\.\d{2}$
this should work fine for you.
/cadi
|
|
|
|
|
Hi you can check www.Regexlib.comfor any regex and you can use the Regulator[^] Expresso[^], Regulator is better as it uses one webservice to search regexlib.com, you will find a repository of regexes there, enjoy it !
Kareem Shaker
|
|
|
|
|
g'day folks,
i am stuck on a small problem relating to the usage of outlook dll in c#. The problem is that I am creating an email using the outlook dll and appending all files listed in a listview as hyperlinks. My copy of outlook displays my signature in every email it creates. Therefore all hyperlinks inserted in the email are inserted at the bottom of the email. What change do I need to make to my code so that it inserts the hyperlinks at the start of the body ?? I am hoping someone could point me in the right direction.
At the bottom is a snipet of my code. As you can see from the code that the line " oMailItem.Display(false);" is repeated twice. The first declaration is done because it displays the email itself and allows the signature in the email to be displayed. If this line is commented then you get an email with no signature but only hyperlinks. Which is not what i want.
I would really appreciate some assistance on this.
thanks
Vee
<code>
private void createEmail(object sender, System.EventArgs e)
{
string InternalPosting ="";
string PostingNotice ="";
string EmailBody="";
string sHtml="";
oApp = new Outlook.Application();
oNameSpace= oApp.GetNamespace("MAPI");
oNameSpace.Logon(null,null,false,true);
oOutlookFolder = oNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail);
Outlook._MailItem oMailItem = (Outlook._MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
oMailItem.Display(false);
foreach (ListViewItem lvitem in listView3.Items)
{
int index = int.Parse(lvitem.Index.ToString()); string filename = EMAIL_ATTACH_LIST[index].ToString();
int lastindex = filename.LastIndexOf('\\');
string displayFilename = filename.Substring(lastindex+1, ((filename.Length) - (lastindex+1)));
sHtml = "<html>\n"+ "<head>\n"+ "</head>\n"+ "<body>\n"+
"<a href= "+"\""+InternalPosting+"\">"+displayFilename+"</a>\n"+
"</body>\n"+"<br>\n"+"</html>";
oMailItem.HTMLBody += sHtml;
}
oMailItem.Display(false);
}
</code>
|
|
|
|