|
The title says it.
Please help. Thanks.
|
|
|
|
|
How about this. Will check to see if registry key exists.
using Microsoft.Win32;
...
string keyName=...;
string valueName=...;
object defaultValue=...;
object o=Registry.GetValue(keyName,valueName,defaultValue);
if (o!=null) {
}
else {
}
|
|
|
|
|
Hello
I am trying to rename a Direcotry/folder in windows
My way to do it goes like this:
private void RenameFolder(DirectoryInfo dir, string NewName)
{
FileInfo fl = new FileInfo(dir.FullName);
fl.MoveTo(string.Concat(dir.Parent + "\\" + NewName));
}
My question is if this is the best way to rename a directory/folder?
Thanks
QzRz
|
|
|
|
|
Hi.
You can also use Directory.Move(string src,string dest)
Or even DirectoryInfo.MoveTo()
So to use your existing code, this can be simplified to:
private void RenameFolder(DirectoryInfo dir, string NewName)
{
dir.MoveTo(Path.Combine(dir.Parent.FullName,NewName));
}
Graham
-- modified at 17:12 Sunday 18th June, 2006
|
|
|
|
|
Hi
Thanks for the reply
Didnt think of you way to do it, thanks
|
|
|
|
|
Hi guys!
Please I need help. I have an MDI form which has click events for ADD, MODIFY and DELETE all these go to the same form which is the "ADD FORM".
For MODIFY AND DELETE click; I need to run a SQL query that will load the data from SQL tables into the textboxes. My question when I open the ADD FORM; how do I process it according to which click made the entry.
i.e.
If (ADD button was clicked from Mdi form)
InitializeComponent()
else if (MODIFY or DELETE were clicked)
connect to SQL table and load data into textboxes
else
I hope this makes sense, all I need help with is how to process the form based on the click.
Please help! thanks in advance.
sasa
|
|
|
|
|
You test the sender object to determine what action to tak:
private void ButtonHandler(object sender, System.EventArgs e)
{
if(sender == this.buttonAdd)
{
}
else if(sender == this.buttonModify)
{
}
else if(sender == this.buttonDelete)
{
}
}
- It's easier to make than to correct a mistake.
|
|
|
|
|
I am assuming I create this function in the ADD form, I did that and then I guess I just have to call it in the beginning initialization after InitializeComponent(). Please don't mind my ignorance but how do I call this Button Hander function. I am calling it using this.ButtonHandler() and it gives me an error saying no overload for method ButtonHandler takes 0 arguments.
Please help! I want to verify which button was clicked in the ADD form and not the MDI form where the buttons are. I.e. Once I am in the ADD FORM I want to check which button was clicked, Add, Modify or Delete. If mdiform.add was clicked then do something else do something else.
sasa
-- modified at 19:37 Sunday 18th June, 2006
|
|
|
|
|
There seems to be some confusions in your code.
SASA_1 wrote: I am assuming I create this function in the ADD form,...
Not exactly. What I created in the previous post is an event handler(delegate). When a button on the MDI form is clicked, the event will be handled in the MDI form, not the ADD form. Thus, the event handler has to be defined by the MDI form class.
That being said, from within the event handler, the MDI form still can call into the ADD form any proper way you want. For example, in the event handler, you may define a button type parameter and pass it to the callback function of the ADD form. Then, the ADD form may take different action based on which button is clicked.
Hope this helps.
- It's easier to make than to correct a mistake.
|
|
|
|
|
Thanks Jun Du for your help. I just decided to recreate another form for modify and delete. That was an easier approach on my side.
sasa
|
|
|
|
|
Hi, How can I use edit, Update, Delete coloumns in DataGrid in Windows application as we use in web,
hope that u send me a sample
Thanks alot
Hamody
|
|
|
|
|
In the index of your MSDN write "DataGrid control [Windows Forms]"
You should have an article talking all about it.
|
|
|
|
|
I'm using the graphics drawstring function to display a whole page of text. Can can I make some of the text linkable?
|
|
|
|
|
I think you'd have to draw the "blue" text yourself, handle the mousemove event to change the cursor and handle the mousedown / mouseup / click event and decide where the mouse was and if the link is to be activated.
Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9
|
|
|
|
|
Have you tried using System.Windows.Forms.LinkLabel class?
Graham.
|
|
|
|
|
can it handle both painted text and link label at the same time?
I tried using both painted text and label (not link label) and the painted text were not displayed. So I assumed it would have the same problem?!!!?
|
|
|
|
|
Yes, the control handles the user interaction of the hyperlink for you and renders the text and link both at the same time. It will even change the color of the hyperlink when visited (akin to IE/Firefox and other browsers).
Just locate the control as the position you require using .Location
|
|
|
|
|
It seems working now. Thanks a lot.
|
|
|
|
|
I've just started c sharp a few weeks ago and I need help on an about box.I have the Aboutbox Class and my main program.How do I make the about box pop up, like in a link or somthing?I've gotten close but the program says I'm using AboutBox as a variable.
-- modified at 10:13 Sunday 18th June, 2006
|
|
|
|
|
Post some code please. But usually you do something like this:
AboutBox box = new AboutBox();
box.Show();
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
Hi everybody!
I'm trying to use DCC protocol on IRC to transfer file. I did a small client who connect on IRC and there is no problem. The problem is at the moment to accept a file.
Dcc is working like that:
On a connection:
* Accept the connection.
* Close the original passive socket.
* Conduct transaction on the new socket.
Acceptor:
* CTCP DCC request received.
* Record information on the DCC request and notify the user.
* At this point, the USER should be able to abort (close) the request, or accept it. The request should be accepted with a command specifying the sender, type, and argument, or a subset of these where no ambiguity exists.
* If accepted, create a TCP socket.
* Connect the new socket to the address and port supplied.
* Conduct the transaction over the socket.
What i'm receiving on IRC looking like that:
:SenderNickName!Sender@Userhost.com PRIVMSG MyNickname :DCC SEND "afilename" 67975159 4503 3190353
After the filename, this is the IP, the port to use, and the filesize!
I'm supposed to connect on this IP and PORT using a socket (Well, I THINK) but it doesnt work. I always get an error message telling that my connection has been refused!
This is what I tried to do for the connection:
long ip = long.Parse(txtIP.Text);
int port = int.Parse(txtPort.Text);
Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
s.Connect(new IPEndPoint(new IPAddress(ip), 0));
If anyone know a solution, it would really help me!
Thanks
Max, Dinamik.ca!
|
|
|
|
|
Socket connection refused?
A couple of things come to mind: What protocol? You specify IP, could it be that you need UDP?
Of course, the only other two options are the ip address and the port.
You may have something wrong with the IP address, port or Protocol. In Java, the IP address is a type in and of itself, in the example above, you've specified it as a long. At the link level it does indeed get translated at the packet layer as a long.
If you feel that all of your vars. are correct, then the other side simply isn't listening. You can download Ethereal and trace the data flow.
What you should see in the trace is this;
Syn ------->
<-------Syn Ack
Ack-------->
If you see a Syn ----> with no response, the server is not listening.
If you see all three, then you are in session and must follow the DCC protocol. If a Fin or Rst flies after you are in session from the other side you are not following the protocol.
|
|
|
|
|
Can anyone tell me a regular expression for date of format dd/mm/yyyy?
Thanks in advance.
|
|
|
|
|
That depends on what you are trying to do. If you want to verify the basic format, a simple pattern like "^\d\d/\d\d/\d\d\d\d$" would do. You could make it more complex to verify if the date looks reasonable, but verifying if the date is truly a valid date is beyond the scope of regular expressions.
---
b { font-weight: normal; }
|
|
|
|