|
I wrote one that does not extend the ListView
http://www.codeproject.com/cs/miscctrl/vivantlist.asp
However, I would suggest you wait until I publish the rewrite. I have a post about version 3.0 on the page. I am currently using it in a project, so it is basically done. I just need to clean it up and write an article on how to use it. So far results are good, on my 1 GHz machine; it can load 100,000 items in 18 seconds, and 10,000 in under a second, where each item has two controls in it. On a 1.4 GHz, it has done 100,000 in 8 seconds.
I dissected the Shape Library example published by Microsoft many times to get a control designer working on a component. I would recommend if you want to learn more on the subject of controls, you take a good look at the Shape Library.
http://windowsforms.net/articles/shapedesigner.aspx
|
|
|
|
|
Thx for links...that m$ thing looks to have alot of good stuff inside.
|
|
|
|
|
I am a newbie to C# so please excuse if this problem is really something simple.
I am trying to create an app that sets a window to maximized state after it recieves a certain command over a TCP port. I can get the tcp listener to work but I cant get the form to display. The form never even shows up. I only get the runtime error "Object reference not set to an instance of an object" after I enter the command via the network to set the form to maximized. I think the problem has to do with my calling a method from within the constructor when the constructor has not yet finished. I have attached my code if anyone is willing to look and suggest where I might find where I am going wrong.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
namespace networkScreenBlanker
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
this.Run();
//
// 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()
{
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Name = "Form1";
this.Text = "Form1";
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
}
#endregion
private void Run()
{
IPAddress localAddr = IPAddress.Parse("127.0.0.1");
TcpListener tcpListener = new TcpListener(localAddr, 65000);
tcpListener.Start();
for(;;)
{
Socket socketForClient = tcpListener.AcceptSocket();
if (socketForClient.Connected)
{
//Console.WriteLine("Client connected");
//SendFileToClient(socketForClient);
NetworkStream networkStream = new NetworkStream(socketForClient);
System.IO.StreamReader streamReader = new System.IO.StreamReader(networkStream);
string inputString;
inputString = streamReader.ReadLine();
if (inputString != null)
{
if (inputString == "blankScreen")
{
Form1.ActiveForm.WindowState = System.Windows.Forms.FormWindowState.Maximized;
}
//Console.WriteLine("Disconnecting from client...");
socketForClient.Close();
//Console.WriteLine("Exiting...");
break;
}
}
}
}
//[STAThread]
public static void Main()
{
Application.Run(new Form1());
}
}
}
|
|
|
|
|
Yes you are correct. The code is halting within Form1.Run() (called from the constructor) so execution never reaches Application.Run(new Form1()), which is the reason you never see the form open.
To acheive the result you require can be acheived by running the Form1.Run() method as a seperate worker thread which can be achieved something like:-
public class Form1 : System.Windows.Forms.Form
{
private Thread trdTcpActivityListener = null;
public Form1()
{
InitializeComponent();
trdTcpActivityListener = new Thread(new ThreadStart(this.Run));
trdTcpActivityListener.Start();
}
public void Run()
{
TcpListener tcpListener = new TcpListener(IPAddress.Any, 65000);
tcpListener.Start();
while (true)
{
if (tcpListener.Pending())
{
Socket socketForClient = tcpListener.AcceptSocket();
socketForClient.Close();
this.WindowState = FormWindowState.Maximized;
}
Thread.Sleep(30);
}
}
}
Now whilst the worker thread waits for a TCP connection, the main thread is allowed to continue,
the constructor completes and the form opens (minimized). Ill leave it up to you to work out when you should stop the worker thread.
|
|
|
|
|
Thanks for the suggestion. This worked. Now to read that chapter on threading.....
Jackson
|
|
|
|
|
I have a Windows Forms app, with two listviews, separated by a splitter control. Both listviews have vertical scrollbars. I want to make sure that if the user moves the scrollbar in either of the listviews, the other scrollbar should also move.
Any ideas?
Thanks a lot in advance.
-KMAnsari
|
|
|
|
|
Hi there,
I'm trying to consume a web-service that is supposed to return a
collection of a custom object. The web-service was not created with C# or
VS.net. It was created with IBM VisualAge Smalltalk 6. I haven't had
problems consuming other web-services but c# seems to choke with
"Collection" return types. The collection (or array) is supposed to
contain three instances of a custom object called PsmWsResult, which has
two variable members: code, and description.
If you'd like to try to see an example of this problem you can add the
following web-reference to your project:
http://216.18.68.93:9999/CollectionWsInterface.wsdl
(The browser window will say that there are no functions found, but they
are there)
After adding the web-reference and renaming it "CollectionsTest", I
created a plain vanilla windows app and inserted the following into the
form load event:
CollectionsTest.CollectionWsInterface ws =
new CollectionsTest.CollectionWsInterface();
//PsmWsCollection seems to be the return object
//which is supposed to be a collection.
CollectionsTest.PsmWsCollection wsCollection;
wsCollection = ws.getCollection();
At this point, the debugger halts execution here:
"CollectionsTest\Reference.cs"
-------------------------------
[System.Web.Services.Protocols.SoapRpcMethodAttribute
("http://www.CollectionWsInterface.com/CollectionWsInterface-
interface/getCollectio" +
"n", RequestNamespace="urn:CollectionWsInterface",
ResponseNamespace="urn:CollectionWsInterface")]
[return: System.Xml.Serialization.SoapElementAttribute("outMsgText")]
public PsmWsCollection getCollection() {
//debugger breaks at the following line!
object[] results = this.Invoke("getCollection", new object[0]);
return ((PsmWsCollection)(results[0]));
}
-------------------------------
The first lines of the stack trace:
-------------------------------
Unhandled Exception: System.InvalidOperationException: There is an error
in XML document (16, 14). ---> System.InvalidCastException: Cannot assign
object of type WindowsApplication3.CollectionsTest.PsmWsResult to an
object of type WindowsApplication3.CollectionsTest.PsmWsResult[].
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Rea
d1_PsmWsCollection()
-------------------------------
Which leads me to believe that the collection is being returned as an
array itself. I'm stuck at this point, how do I cast the return type to
be an array of itself??
If I try the following:
wsCollection = (CollectionsTest.PsmWsCollection[])ws.getCollection();
I get a "Cannot convert type" error when compiling.
I tried invoking the getCollection function using "Web Service Studio"
and it chokes on it as well!
If anyone has any clue on what I should do to correct this, I'd
appreciate it!
Thanks!
Jorge
|
|
|
|
|
Unfortunately, I can't pull up your WSDL file to see what datatypes it is using. It looks like the XML being returned does not match the XML Schema defined in the WSDL file.
To start looking into this, click the show all files icon in the project viewer and expand the web reference until you see the reference.cs file. You should be able to see the data types that the method is returning.
Get a tool like httpLook[^] and look at the XML that is actually being sent. There should be a very simple correspondence between the return types and the XML.
If not then the WSDL does not match the data being sent and you are probably going to need to learn more about XML Schema then you ever wanted to know to sort the problem out. Comparing the generated types and the actual data should get you started in the right direction though.
I can imagine the sinking feeling one would have after ordering my book,
only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
|
|
|
|
|
Hi all ,,, a have an exception message when i try to create a TcpClient in win socket says : lack of memory or queue is full .
iI am using winXP Pro , C#, port no > 1024 ( is it OK ?) , and on toshiba laptop.
what is the solution please .
Thanks to you all
|
|
|
|
|
From the information you have given us we can't help you much.
Well I guess you "ran out of memory or your queue is full". This is mostly like a debugging task you'll have to do on your own... check all your code.
Also, please dont post same thing twice.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Getting the inner exceptions can help understand the problem sometimes. Could you post the inner exception messages?
try
{
// ... do whatever ....
}
catch (Exception ex)
{
Console.WriteLine (ex.Message);
Exception innerEx = ex.InnerException;
while (innerEx != null)
{
Console.WriteLine (ex.Message);
innerEx = innerEx.InnerException;
}
}
|
|
|
|
|
Hi all ,,, a have an exception message when i try to create a TcpClient in win socket says : lack of memory or queue is full .
iI am using winXP Pro , C#, port no > 1024 ( is it OK ?) , and on toshiba laptop.
what is the solution please .
Thanks to you all
|
|
|
|
|
I remember that i have read something like this before
your port must be between 50001 and something else i don't know
ByMindOnlyYouCanDoIt
|
|
|
|
|
As far as I know there are no limitations on port numbers. There's only suggestion to stick with the standard...
"The Internet Assigned Numbers Authority (IANA) defines port numbers for common services (see www.iana.org/assignments/port-numbers). Services not on the IANA list can have port numbers in the range 1,024 to 65,535."
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
I am trying to automate conversion of powerpoint files to html. I have developed this as a windows service and here is the conversion code:
<br />
...<br />
PowerPoint.Application ppApp = new PowerPoint.Application(); <br />
PowerPoint.Presentation prsPres = <br />
ppApp.Presentations.Open(targetFile, Microsoft.Office.Core.MsoTriState.msoTrue, <br />
Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);<br />
string testStr = prsPres.Name;<br />
string fileHTM = filePath.Replace(".ppt", ".html");<br />
prsPres.SaveCopyAs(fileHTM, PowerPoint.PpSaveAsFileType.ppSaveAsHTML, Microsoft.Office.Core.MsoTriState.msoTrue);<br />
prsPres.Close();<br />
ppApp.Quit();<br />
...<br />
The problem is that if i am not the original author of the application, the application will ask me for a confirmation to save changes as revisions.
Is there a way to disable revisions programatically since this application is running as a service.
|
|
|
|
|
You'll be lucky if someone here has some experience with this. This place is specifically for C#. Although you are using C# lang its still a PPT question.
My suggestion is to post at MS newsgroups
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
hi every 1,
i'm trying to do some program that drow a clock like the pressure clock : three colors red for danger, yellow for miduim danger and green for no danger. i'll read three values from an excell sheet : 1- danger level 2- target
3- actual level.
these values will help me to drow the clock and the actual value will be pointed on the graph using an arrow..
can any 1 give me a hint of what can be done in here ????
thanx inadvanced
|
|
|
|
|
This is straight forward painting problem. First you have to create a design. Do you want something elaborate or something simple?
Next step is to use System.Drawing namespace and Graphics object to do FillRectangle, DrawLine and so forth. If you have something more complex you might want to use DrawImage. See MSDN for more information
Do you have a more specific question?
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
hi thanx 4 ur help here is my code :
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace mesure
{
///
/// Summary description for Form1.
///
///
public class Form1 : System.Windows.Forms.Form
{
Graphics g ;
int x=0;
/*SolidBrush b1 = new SolidBrush(Color.Red);
Pen p1 = new Pen(b1,5);
SolidBrush b2 = new SolidBrush(Color.Green);
Pen p2 = new Pen(b2,5);
SolidBrush b3 = new SolidBrush(Color.Yellow);
Pen p3 = new Pen(b3,5);
SolidBrush b4 = new SolidBrush(Color.Black);
Pen p4 = new Pen(b4,2);*/
Rectangle rect1 = new Rectangle(15,35,100,100);
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox Green;
private System.Windows.Forms.TextBox Red;
///
/// 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()
{
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.Green = new System.Windows.Forms.TextBox();
this.Red = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(96, 296);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(128, 248);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 1;
this.textBox1.Text = "";
//
// label1
//
this.label1.Location = new System.Drawing.Point(32, 168);
this.label1.Name = "label1";
this.label1.TabIndex = 2;
this.label1.Text = "Red Value";
//
// label2
//
this.label2.Location = new System.Drawing.Point(32, 200);
this.label2.Name = "label2";
this.label2.TabIndex = 3;
this.label2.Text = "Green Value";
//
// Green
//
this.Green.Location = new System.Drawing.Point(136, 200);
this.Green.Name = "Green";
this.Green.TabIndex = 5;
this.Green.Text = "";
//
// Red
//
this.Red.Location = new System.Drawing.Point(136, 168);
this.Red.Name = "Red";
this.Red.TabIndex = 7;
this.Red.Text = "";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 326);
this.Controls.Add(this.Red);
this.Controls.Add(this.Green);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
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 button1_Click(object sender, System.EventArgs e)
{
double pi = 22.0 / 7.0;
double a = 50*Math.Cos(x*pi/10);
double b = 50*Math.Sin(x*pi/10);
int red = int.Parse(Red.Text.ToString());
int green = int.Parse(Green.Text.ToString());
x = int.Parse( textBox1.Text.ToString());
float x1 = 64+float.Parse(a.ToString()) ;
float y1 = 85-float.Parse(b.ToString());
g.FillPie(new SolidBrush(Color.Red),rect1,-(180-((18*red)+(18*green))),18*red);
g.FillPie(new SolidBrush(Color.Green),rect1,180,(18*green));
g.FillPie(new SolidBrush(Color.Yellow),rect1,(-18*red),-(180-((18*red)+(18*green))));
g.DrawLine(new Pen(Color.Black,2),x1,y1,64,85);
// drowPie();
}
private void Form1_Load(object sender, System.EventArgs e)
{
g = this.CreateGraphics();
drowPie();
}
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
// drowPie();
}
private void drowPie()
{
}
}
}
the problem is how to get the data from an excell sheet not from the text box's like i did.
any thing will help to update this code
help is realy need.
|
|
|
|
|
You shouldn't create a new Graphics object to do painting. You need to go with the standard way of painting and that is... either override the OnPaint of a control or handle the Paint event. It looks like you started something in the Form's Paint event handler I dont now why you dropped that
Getting data from excell is a different question. I dont have time for a detailed answer so I suggest you search the forum and google.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Q: I have an app which reads in an XML doc of services to start up when they go down.
I see that the ServiceController class has the method WaitForStatus, and it can take a TimeSpan param.
If the service has not started , the method throws the TimeoutException exception.
If I have the method inside of a TRY-CATCH-FINALLY block, does that mean that code execution will stop untill either the service starts up or the time expires? Or will the code proceed to the FINALLY block if there is no error before the TimeSpan expires?
thanks,
sprout
|
|
|
|
|
If an exception is not thrown your try block will be executed sequentially until finished, then the finally block is executed. If an exception is thrown, the appropriate catch block is executed, then the finally block is executed.
The finally is always executed except when you terminate the CLR using Environment.Exit .
See the C# language specification in the VS.NET product documentation or online at http://msdn.microsoft.com/library[^] for more information.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thank you for the reply!
So that means that even if the method WaitForStatus has a time span of say 3 minutes, the code in the try block will not execute the FINALLY block untill the either the servie has started successfully or the time has expired and then the exception is throw, which is handled in the CATCH?
So the program will pause until the the service starts or an exception is thrown?
Thanks for all the help!!
|
|
|
|
|
|
Hi,
I've a FTP server, which is a Unix box, and here are some 100s of log files reside.
Also, I'm trying to develope an application in C# where at one point i need these log files to be copied to the developement machine [which on the later date going to be small App Server, anyways,].
Now, my problem is these log files are going to be updated daily and I need to analyze them on daily basis. It would be awesome if I could just write a small program in C# which will just transfer these files on the developemtn machine on the back-ground.
Although I think .net remoting or .net's System.net might be usefull I have no idea about that.
I would really apreciate if you could tell me 2 things...
1) If it is at all possible [withought user intervention, coz path and file name convesion n everything is all fixed, and its not going to change]
2) If it is possible, I would appreciate if i could get a little push towards the right direction
thanks
|
|
|
|
|