|
Hi All,
This is my first post in the C# section. Hope I get a reply.
In my windows form application I have a TreeView on the left side of a splitter control. Tree nodes can have 2 labels say, A and B.
If the user selects a node with A label on it, I want to show a form with some controls on the right side of the splitter.
If the user selects a node with B label on it, I want to show a different form with different controls on the right side of the splitter.
Can anyone suggest a method for form switching the way I want?
Please dont ask me to use only one form and show and hide controls depending on the tree node selection.
Your help will be much appreciated.
TIA
Binayak
|
|
|
|
|
|
You could have also used User Controls. They would have been easier to work with since they would have each been their own class.
|
|
|
|
|
How can I kill a running process with the Win32 api ? I know that I have to use a Process ID, but how can I resolve this one ? Thanks for each response.
|
|
|
|
|
You can do this through the .NET Framework, there is a Kill method defined in the Process class. Check into here: Process.Kill[^].
- Nick Parker My Blog | My Articles
|
|
|
|
|
Morning All -
I have a unix file / and Stream output that uses ^M [CTRL-M CR (Carriage return) ] to end a line. I see the line break's in MS Wordpad, but not in Notepad or when trying String.Split(char [], ...) I do not know what char to define.
Can anybody help, or point me in the right direction.
thx,
CJ
|
|
|
|
|
Are you writing the file or reading it? By default, TextWriter.NewLine is the same as Environment.NewLine . If you need to change this, you can set the NewLine property to any string necessary on classes that extend TextWriter (like StreamWriter ).
If you're reading files using classes extending the TextReader , many take an optional parameter (via overloads) to the control to automatically detect the file encoding, which most often checks the line-endings as well (IIRC). Take a look at the overloaded constructor documentation for the StreamReader class in the .NET Framework SDK for more information.
If you're wondering why wordpad.exe displays ^M it's most likely because it hasn't been updated to handle different line endings while notepad.exe has.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
|
Hi All!
I come from a VB background and have been doing .NET for a year or so, and am looking for a way to yield / update my GUI every now and then when doing long operations (the occational check for ESC-keys, mouseclicks, etc).
I guess I could do it with API's, but since many of the API's I used with VS6 is now integrated in the framework, I thought it was a solution to this too?!? I use Net2003 Framework 1.1.
Any gurus out there?;)
TIA
-Per
|
|
|
|
|
Bibl2Frogn wrote:
and am looking for a way to yield / update my GUI every now and then when doing long operations
You should look into threading. The Thread[^] class has more information, I would start there. There is also Application.DoEvents[^] which will process all messages in the message queue. This should get you started.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Thanks Nick. I'll look into it.
-Per
|
|
|
|
|
To All:
This is a very simple and stripped down example of what I am thinking about. The question is as follows:
If given an array of items, such as string [] arrMeth = new string [] { "A", "B", "C" } , can one take anyone of these items (A, B, C) and use it in the invocation of a Foo method acting as the method name?
If it is not possible, then please state so; however, if this is a possibility, please provide an example of how to do so.
Thanks in advance to all the respond. Example code is provided below.
Sincerely,
DeadPoet
<br />
using System;<br />
namespace dp.test<br />
{<br />
class Test<br />
{<br />
[STAThread]<br />
static void Main( string[] args )<br />
{<br />
string [] arrMeth = new string [] { "A", "B", "C" };<br />
<br />
Foo foo_obj = new Foo();<br />
foreach ( string xMeth in arrMeth )<br />
{<br />
foo_obj.xMeth( xMeth );
}<br />
<br />
}
}
}
<br />
<br />
using System;<br />
namespace dp.test<br />
{<br />
class Foo<br />
{<br />
public Foo() {}<br />
public void A ( string x )<br />
{<br />
Console.WriteLine( "Method " + x );<br />
}<br />
public void B ( string x )<br />
{<br />
Console.WriteLine( "Method " + x );<br />
}<br />
public void C ( string x )<br />
{<br />
Console.WriteLine( "Method " + x );<br />
}<br />
}<br />
}
|
|
|
|
|
Yes, this is possible but not as you state it. You need to look into the Reflection[^] namespace. In particular, you can do something like the following (I didn't test this but it should get you started):
MethodInfo mi = typeof(WindowsIdentity).GetMethod("GetRoles");
if(mi != null)
{
string[] roles = (string[])mi.Invoke(new WindowsIdentity(), null);
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
I have created a client in C# and a server in C. The Server is run on a linux computer and client on Windows. When the client tries to connect it fails. I have tried modifiyng the server to run on windows, and I am able to establish the connection between two windows computers. It also seems to work connecting a linux version of the client to the server on linux. But it doesn´t work connecting a c# version on windows to the c server on linux.
|
|
|
|
|
What protocol are you using to connect the client to the server? I'm mean have you written your own webserver, or some custom protocol on top of TCP/IP, or what?
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
I use TCP Client class in the C# client program to connect to the server. I use the accept method in the c-written server to accept the incoming socket connection.
|
|
|
|
|
Hi,
my query is two-fold. Firstly, when exporting a datagrid (filled with Oracle data) to Excel the resulting .xls file is quite large(at least 6 MB) and is quite a slow load into Excel. I was wondering how to make it smaller (and quicker to load). Each query is about 6000 rows at least, all of which are required.
Secondly, can I export it to any other format other than .xls? I am able to produce .xml files but would like to produce .csv files if possible? Smaller .xls files would be perfect.
The saveFileDialog1.Filter method currently contains .xls as when I've tried to include .csv the file is written as Xml, is over 65000 lines and is therefore truncated by Excel.
I'm sure its just sloppy coding on my part (trainees eh?) so any advice/tips would be appreciated.
Thanks for reading
Scott
|
|
|
|
|
Hi,
I am trying to implement a list box in which each item is a button control with bitmap.
How can this be done?
Thanks
kalpu
|
|
|
|
|
Hello
Can anybody provide me code that how we can use our personal computer (running windows 2000, C#) as a FTP server.
I am a fresher in this Topic.
So please make the code simple.
Thanks
Sharad
|
|
|
|
|
You want to do it programmatically or manually?
Manual solution:
Install IIS on windows 2000. That will install SMTP and FTP services. Just enable the FTP service and your computer is a FTP server.
Programmatic Solution:
See whether System.Net.WebClient solves your purpose.
|
|
|
|
|
Hello,
I already have spoken about my problem in this forum. I developed a Smart Device Application with a Login function. After the login function a screen with some information is displayed for about five seconds and then be automatically forwarded to the next Form. I wrote a little code sample and wouuld ask if this is correct to solve my problem?
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
namespace SmartDeviceApplication2
{
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.MainMenu mainMenu1;
private static AutoResetEvent evt;
private static int count = 5;
public Form1()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(64, 64);
this.textBox1.Text = "textBox1";
//
// label1
//
this.label1.Font = new System.Drawing.Font("Monotype Corsiva", 18F, System.Drawing.FontStyle.Italic);
this.label1.ForeColor = System.Drawing.Color.LawnGreen;
this.label1.Location = new System.Drawing.Point(16, 8);
this.label1.Size = new System.Drawing.Size(160, 24);
this.label1.Text = "Test";
this.label1.TextAlign = System.Drawing.ContentAlignment.TopCenter;
//
// button1
//
this.button1.Location = new System.Drawing.Point(64, 136);
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label2
//
this.label2.Location = new System.Drawing.Point(64, 104);
this.label2.Text = "label2";
//
// Form1
//
this.BackColor = System.Drawing.Color.Orange;
this.Controls.Add(this.label2);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox1);
this.Menu = this.mainMenu1;
this.Text = "Form1";
}
#endregion
static void Main()
{
Application.Run(new Form1());
evt = new AutoResetEvent(false);
Timer t = new Timer(new TimerCallback(TimerCallback), null, 5000, 0);
evt.WaitOne();
ActiveForm = Form2;
}
private void button1_Click(object sender, System.EventArgs e)
{
label2.Text = textBox1.Text;
tw.Write("This is the first message!");
}
private static void TimerCallback(object state)
{
evt.Set();
}
}
}
Thanks in Advance
regards
mathon
|
|
|
|
|
Hello,
I want to develop my own control for table which contains links which
referes to other Forms of a Smart Device Application for PocketPc. Does there any code samples exist which show such a development?
thx
regards
patrick
|
|
|
|
|
How do you create a user control by name in code.
Say I read in control names from a file. How do I then create them in code. In VB6 there was a CreateObject method but I can't find anything similar in C#
|
|
|
|
|
|
Thanks Stefan,
I used the Activator class to create the user control by assembly name and user control namespace and name e.g.
public static object CreateOject(string AssemblyPathName, string NamespaceClass)
{
Assembly assembly;
//Can be used when instance in another assembly
try
{
assembly;= Assembly.LoadFile(AssemblyPathName);
}
catch (System.IO.FileNotFoundException e)
{
throw an exception
}
System.Type TypeToCreate = assembly.GetType(NamespaceClass);
if (TypeToCreate == null)
{
throw an exception;
}
return Activator.CreateInstance(TypeToCreate);
}
Note you don't have to create the assembly object if the type is part of the same assembly or GAC, you can just get the Type by:
Type TypeToCreate = Type.GetType(NamespaceClass);
|
|
|
|