|
About leaky code...
I suggest you get yourself a profiler. True lifesaver. There are bugs that are nearly impossible to find without one. Try the one from SciTech... memprofiler.com[^]. They also have a great tutorial on the website.
Alex Korchemniy
|
|
|
|
|
hi
i got some of the word events from mocrosoft.com using c#,but i want scrollbar events for word in c#,could u plse help me on this topic!!!!
lllisha
|
|
|
|
|
Hi there ,
Am wants to achieve OVERLAPPED I/O so am using these
ReadFile, n Accept fuctions n am getting problem can anyone help me about using these functions or
can anyone send me A simple Client Server Application using
ReadFile, Accept methods in C#.net
if someone interested than i will send ma code for correction
Regards.....
Babar
Babar
|
|
|
|
|
Here is the code for my problem.Copy paste it and then try to drag item from listView to TreeView.sometimes code works and soem times it does not works at all.Please help
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Drag_n_Drop_ListView_To_TreeView
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TreeView treeView1;
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.Label label1;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
System.Windows.Forms.ListViewItem listViewItem1 = new System.Windows.Forms.ListViewItem("Item1");
System.Windows.Forms.ListViewItem listViewItem2 = new System.Windows.Forms.ListViewItem("Item2");
System.Windows.Forms.ListViewItem listViewItem3 = new System.Windows.Forms.ListViewItem("Item3");
System.Windows.Forms.ListViewItem listViewItem4 = new System.Windows.Forms.ListViewItem("Item4");
this.treeView1 = new System.Windows.Forms.TreeView();
this.listView1 = new System.Windows.Forms.ListView();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// treeView1
//
this.treeView1.AllowDrop = true;
this.treeView1.HideSelection = false;
this.treeView1.ImageIndex = -1;
this.treeView1.Location = new System.Drawing.Point(0, 0);
this.treeView1.Name = "treeView1";
this.treeView1.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node0", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node3", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node4", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node5")})}),
new System.Windows.Forms.TreeNode("Node6")}),
new System.Windows.Forms.TreeNode("Node1", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node7", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node8", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node9", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node10")})})})}),
new System.Windows.Forms.TreeNode("Node2"),
new System.Windows.Forms.TreeNode("Node11", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node12", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node13", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node14", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node15")})}),
new System.Windows.Forms.TreeNode("Node16", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node17", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node18")})})})})});
this.treeView1.SelectedImageIndex = -1;
this.treeView1.Size = new System.Drawing.Size(168, 304);
this.treeView1.TabIndex = 0;
//
// listView1
//
this.listView1.Items.AddRange(new System.Windows.Forms.ListViewItem[] {
listViewItem1,
listViewItem2,
listViewItem3,
listViewItem4});
this.listView1.Location = new System.Drawing.Point(168, 0);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(352, 304);
this.listView1.TabIndex = 1;
this.listView1.View = System.Windows.Forms.View.List;
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 312);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(208, 16);
this.label1.TabIndex = 2;
this.label1.Text = "Drag n Drop From ListView To TreeView";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(520, 333);
this.Controls.Add(this.label1);
this.Controls.Add(this.listView1);
this.Controls.Add(this.treeView1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
listView1.ItemDrag+=new ItemDragEventHandler(listView1_ItemDrag);
treeView1.DragEnter+=new DragEventHandler(treeView1_DragEnter);
treeView1.DragDrop+=new DragEventHandler(treeView1_DragDrop);
}
private void listView1_ItemDrag(object sender, ItemDragEventArgs e)
{
string strItem = e.Item.ToString();
// Start the Drag Operation
DoDragDrop(strItem, DragDropEffects.Copy | DragDropEffects.Move);
}
private void treeView1_DragEnter(object sender, DragEventArgs e)
{
// Handle the Drag effect when the listbox is entered
if (e.Data.GetDataPresent(DataFormats.Text))
e.Effect = DragDropEffects.Copy;
else
e.Effect = DragDropEffects.None;
}
private void treeView1_DragDrop(object sender, DragEventArgs e)
{
// Get the Data from the DragEventArguement
string dummy = "hello";
string s = (string)e.Data.GetData(dummy.GetType());
// Parse out the type information
s = s.Substring(s.IndexOf(":") + 1).Trim();
System.Drawing.Point p = new Point(e.X,e.Y);
TreeNode selectedNode = treeView1.GetNodeAt(e.X,e.Y);
// Find the node at this position
TreeNode DropNode = this.treeView1.GetNodeAt(p);
// if the node exists, insert a new node with the dropped string
// into the second tree
if (DropNode != null)
{
TreeNode DragNode = new TreeNode(s);
MessageBox.Show(s);
treeView1.Nodes.Insert(DropNode.Index+1, DragNode);
}
}
}
}
|
|
|
|
|
can custom datasets be used in rdl while generating it programmatically ?
Prithiv Thirugnanasambsandam Vasudevan
|
|
|
|
|
|
My user profile is not Admin.
I wrote a code that sends ping,
it works when I logon with admin password,
but doesn't work when I logon with my user (that is not admin).
Thanks..
|
|
|
|
|
|
Thank you for your reply!
Ok. I got it. I need admin account.
Actually My problem is ;
I wrote a small server (listens tcp port),
when a client's cable unplugged, I want my server detect this,
and says this client is disconnected,
Do you know how can I do it?
thank you very much...
|
|
|
|
|
The server cannot detect this at all. As I put in your other post, PING'ing the client is not a reliable method considering the client might be behind a firewall or NAT that won't let ICMP traffic through it.
The only thing you can do is build in a "keep alive" where the client must send these "keep alive" requests to the server every so often. If the server stops receiving these requests from the client within a specified time period, it can assume that the client is no longer connected.
I don't know how much traffic or how many clients you're expecting, but this has scalability limitations. If you get enough clients connected, you could conceivably have 80%, or more, of the traffic going to the server just "keep alive"'s, resulting in very slow performance.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
That's Right. but my problem is that my clients may anyone. I mean. any client who knows my server IP and Port Number can connect to my server.
that is clients cannot send me message that they are online or something.. because they don't know the way I search them...
They can only send me string messages and my server display it on the received screen.. (of sure incoming messages are token as bytes no problem at this fact at all)..
As a result, server has to detect which clients are online or not! by a way ping or something..
By this way , I know that all the work done by server and server has much work to do.. But I have to...
Thank you very much for reply..
Greetings....
Alper.
Software Developer.
|
|
|
|
|
Your client may be anyone, anywhere on the planet?
Since you're trying to determine if the client disconnects unexpectedly, I'm assuming that you have to keep state information for the duration of the client session. Is this correct?
Are you writing a client piece to this also? If so, then you could include code that would send a "keep alive" request back to the server so the server knows it's still connected. After a certain timeout, if no "keep alive" request has been received by the server, you can assume the client either lost communication or terminated the client for some reason.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Unfortunately I'm writing only the Server Part,
and the clients are electronic cards that
has the client code in their EP-ROM and flash memory.
If their battery gets low or power-off my or their network cable unplugged, my server has to detect it.
Because the memory is very important for the EP-ROM based electronic cards client. Any Keep-Alive Send code couldnt be added into the clients.
Again Thank you very much...
|
|
|
|
|
You could have put that little tidbit into your original post!
Now, your options are extremely limited...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi, im new to C# and have a problem when i must assign methods to objects i create in execution mode.
while in design mode u can create a timer and then double click on it and there u go, but how can i attach a method to a timer i have created in execution time?
<br />
using System.Timers;<br />
<br />
Timer t = new timer(30000);<br />
t.enabled=true;<br />
Ty for ur time.
|
|
|
|
|
Timer t = new Timer(new TimerCallBack(Your Method));
and then handle all the rest
|
|
|
|
|
Declare your Timer
[code]
System.Timers.Timer myTimer = new System.Timers.Timer(1000);
// 1000 is the Interval used by the Timer in ms, i.e. the time between two "Timer.Elapsed" Events
[/code]
Then add an EventHandler
[code]
myTimer.Elapsed +=new System.Timers.ElapsedEventHandler(myTimer_Elapsed);
// Note: In VS.NET 2003, as soon as you type the +=, VS will ask you to press
// TAB. If you do, it will code-complete everything else, even the Delegate's
// body if you press TAB again.
[/code]
Now, on each Elapsed-Event, the Delegate will be executed
[code]
//If you are not using VS.NET, this is what the delegate should look like:
private void myTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
}
[/code]
|
|
|
|
|
TY a lot for your help and examples, it works perfect now.
|
|
|
|
|
I have a tcp server, when a client connects, then let its cable unplugged!
Then How can server detect that it is disconnected?
Thanks all!
|
|
|
|
|
It can't. The only thing it can do is assume that the client dropped the connection without closing it, because of a complete lack of communication for a specified timeout period.
Or, with a little more thought, the server can try and PING the client every so often to see if it is still alive. This has it's problems too considering the client might be behind a firewall that won't let ICMP packets through.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
It isn't really true that the server can't detect that the client disconnected. But the server can't detect it just by sitting there. I had some code somewhere that managed this by having the server periodically switch the socket to nonblocking mode and try to do a read in peek mode. Note that the receive in peek mode might return WSAEWOULDBLOCK if the socket is still live and there is nothing to read on it. But if the socket is closed, it will not return an exception. That is why I preload the bytes[] array with some data that I can then compare the read result against, of course assuming that I would never expect the read to contain that exact byte pattern. There might be a better way, but this worked fine for me.
try
{
// Try doing a dummy read to see if the socket is still alive
bytes[0] = 0xf;
bytes[1] = 0xe;
bytes[2] = 0xd;
bytes[3] = 0xc;
socket.Blocking = false;
socket.Receive(bytes, 0, 4, SocketFlags.Peek);
socket.Blocking = true;
if (bytes[0] == 0xf && bytes[1] == 0xe && bytes[2] == 0xd && bytes[3] == 0xc)
{
// The sender has shut down the socket
bexitreadloop = true;
socket.Close();
form1.DisplaySocketStatusMessage("Lost connection with sender");
break;
}
}
catch (SocketException e)
{
socket.Blocking = true;
int code = e.ErrorCode;
if (e.ErrorCode != WSAEWOULDBLOCK)
{
bexitreadloop = true;
socket.Close();
form1.DisplaySocketStatusMessage("Socket error on read");
break;
}
}
|
|
|
|
|
This is Great, Now I'm working on it.
Thanks for this great reply...
Alper
|
|
|
|
|
im trying to request a web but its needs a proxy with authenticantion i have alredy creat a WebProxy object to setit up the WebRequest.Proxy property but idont know how to configure or setup the WebProxy credentials for this proxy authentification can any one give a hand on this
regards alex
|
|
|
|
|
Hi all,
I have a class that owns a "protected" method (let's say 'Class1'; method: 'AddVar'). Now, I want to use reflection to obtain this class and inherit it to a local class.
Something like:
Public Class LocalClass : Assembly.LoadFrom("..PathToClass1..").GetType("Class1")
I now the line above is too good to be right.
Is what I want even possible? If so, How do I define it?
Thanks
MGKido
|
|
|
|
|
|