|
Since a form hosts both the treeview and the listview, I would override both OnBeforeCheck event handlers, and provide a default implementation to them, calling a unique method at the form level. This method in turn Invokes Check() methods exposed by tree nodes, and list nodes.
Nothing really new to talk about, that's much like delegating the application logic to a control manager.
|
|
|
|
|
Interesting, I guess I've never overridden a windows-fired event... how do you get windows to fire the overridden vs. the non-overridden event?
thanks.
|
|
|
|
|
Silly question probably, but...Whats the easiest way to communicate from a child Window to a parent window. For example, when the app starts, I want a login form to popup. When entered, that data needs to be available throughout the app. Currently I am using the "OnMdiChildActivate" event on the parent window which works, but it seems as if there should be a better way.
Cody C
|
|
|
|
|
You could do this in a couple of ways.
If you are in full control of the form that is poping up, you can get the required information by capturing the OnClosing event of the logon form, add the event handler in your MDI parent's load event when you open the mdi child:
LogonForm f = new LogonForm();
f.MdiParent = this;
f.OnClosing += new EventHandler(this.Form1_Closing);
Having done this, write code along these lines to capture properties from the closing logon form:
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
LogonForm f = (LogonForm)sender;
string Uname = f.Username;
string Pword = f.Password;
}
obviously you'll need to set up properties such as Username & Password in you logon form that are public.
An other way may be to pass up a custom Logon class from the Parent to the child by reference, you can then populate it from the logon form and the information will be available to the parent.
Let me know if you'd like me to elaborate on either of these methods.
|
|
|
|
|
Thanks..thats an interesting idea. I actually did it a different way by when the user logs on successfully, having the child window (logon form) populate some public properties of the parent window. I like the idea of having the parent window handle events of the login window however.
|
|
|
|
|
I have written a simple web service, well it's kind of complexe, but it is working GREAT on my local machine. I can call it via the URL and it does EXACTLY what I want it to do (http://localhost/webServiceName/WebService.asmx/theWebMethod?var1=stingVar1&var2=stringVar2....). So now I want to put it out on my production server. So I follow all the steps that are laid out in this example.
When I run it, I get this error:
==========================================
Server Error in '/agnWmEventTools' Application.
--------------------------------------------------------------------------------
Request format is unrecognized.
Description: An unhandled exception occurred during the execution of the current web request.
Please review the stack trace for more information about the error and where it originated
in the code.
Exception Details: System.InvalidOperationException: Request format is unrecognized.
Source Error:
An unhandled exception was generated during the execution of the current web request.
Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: Request format is unrecognized.]
System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response) +388
System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath) +94
System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, String path, String pathTranslated, Boolean useAppConfig) +718
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() +95
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +173
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.510; ASP.NET Version:1.1.4322.510
==========================================
I know this has to be something simple, right?? The only difference is in the systems running it. When I first put this on, I got an MDAC issue so I upgraded the MDAC on the server running .Net and that error went away and now I get this error above.
Thanks,
Bill K.
|
|
|
|
|
Well nobody answered my question.
However, not all is lost. In digging and doing some reading it seems that .Net framework version 1.1 that these two little lines are commented out
<add name="HttpPost"/>
and
<add name="HttpGet"/> in the machine.config file. Once I un-commented those and saved the file it worked like a charm.
I am just posting this in the hopes that somebody else might learn something from it too. If this was already common knowledge, sorry about posting something so dumb.
Thanks,
Bill K.
|
|
|
|
|
I'm adding objects of a custom class to a check list box and when I call the Add () method of the check list box the string it adds is simply namespace.classname. I don't want it to add this I want it to add a string variable that is declared in the class. I tried overriding the ToString () method because I thought it might be calling that, but it still added the same thing. Does anyone know what method I can override so that it adds the string I want.
Thanks again.
- monrobot13
|
|
|
|
|
Why don't you add that string to the list box instead of adding the object that contains it?
|
|
|
|
|
At first I didn't want to do that becasue I was going to add the whole oject to the list box. I've decided to go a different route since. Now I'm doing exactly that (simply adding the string I wanted) I'm adding the objects into an ArrayList.
Thanks
- monrobot13
|
|
|
|
|
If you did want to go back to your original idea... derive your object from ListViewItem (im doing it with tree's so you might need to check that), and then set its text (no need to overide) to whatever text you want to appear in the list/tree. Then when you add it to the list it will have the exact text that you want.
Hope that helps any one else trying something like this!
On a similary note... Does anyone know how i can add the same TreeViewItem to 2 different TreeView's without having to clone it?
|
|
|
|
|
se99ts wrote:
derive your object from ListViewItem
That's good as a solution to the original issue, although that's questionable in terms of object oriented model : if the object is non GUI related, why should a non GUI object be "attached" to a GUI class ?
|
|
|
|
|
i know it is a dodgy area, but i found it easier just to add the objects to a list, instead of having to store the entries in an array and then just a text representation of them in the GUI, it just meant i didnt have to do any lookup's i could just call the events on the object.
though at this stage i may well have to go to a text representation as the items cant be added to 2 lists, so i may well be doing lookup's!
|
|
|
|
|
se99ts wrote:
though at this stage i may well have to go to a text representation as the items cant be added to 2 lists
Exactly, items are always attached to a unique control parent.
|
|
|
|
|
You need to call ToString() before adding it to the Items collection.
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
I've decided to go a different route (see post above), but thanks for the help anyways.
- monrobot13
|
|
|
|
|
Coming back to the original problem, you can also fill a listbox or combobox by setting the datasource to any object that implements the interface IList.
I had the problem,that I wanted the ValueMember property differently set to the DisplayMember. With the collections Add() method this is not possible.
So I defined a simple class:
internal class clsName
{
private string _longname;
private int _uid;
public string LongName {get {return _longname;} set {_longname = value;}}
public int UID {get {return _uid;} set {_uid = value;}}
public clsName (string lname, int uid)
{
_longname = lname;
_uid = uid;
}
}
and filled the combobox with an arraylist (the parameters come from a xml file):
[...]
_arrNames.Add(new clsName(nav2.Value,System.Convert.ToInt32(iterator.Current.GetAttribute("UID",nav.NamespaceURI))));
[...]
The combobox datasource can then be set to the arraylist and the members to the appropriate custom class properties.
[...]
cb.DataSource = _arrNames;
cb.DisplayMember = "LongName";
cb.ValueMember = "UID";
[...]
That's all and the list is filled with the strings plus the value is set to what I need in the combobox event handler later in the application.
Wolfgang
|
|
|
|
|
There are 2 ways to do this, one of which you have already mentioned.
Firstly you can use the DisplayMember property:
this.checkedListBox1.DisplayMember = "Test"; <br />
Alternatively, as you mentioned, override the ToString() method. Most list type controls use this as the default DisplayMember when it is not set explicitly:
public override string ToString()
{
return this.Test;
}
I'm not sure why this did not work for you before.
Both of these methods worked in a quick demo i wrote up.
|
|
|
|
|
Hi,
I'm new to this Web services thing..., I've been reading a doc that was made by Microsoft and IBM about security... but I'm not an expert in that area...
It seems that SOAP is a layer that has nothing to do with security that would be handled by un upper layer... does this mean that just using SSL would solve my problems ? I have read that is possible to avoid using an SSL line just by having all the encryption thing inside the webservice ( and if the caller has own some password or libraries from us) how does this work ?
Sorry... the terms that I have used are not very profesionals , greetings
Braulio
|
|
|
|
|
There are different ways you can enforce security for a web service.
It can be SSL or it can be something like modifying the soap header for custom authentication.
SOAP intentionally leaves this area upto the implementor (to my knowledge), you can get more info about web services security from here[^]
Hope this helps.
Cheers,
Kannan
|
|
|
|
|
I asked a similar question before, but never really received a response. I'd like to know how to access the controls, variable, etc on one form from another. In VB you can do something like this:
Form1.TextBox1.Text = Form2.TextBox2.Text What I'm wondering is how can I do this in C#? Is it possible?
Thanks in advance.
- monrobot13
|
|
|
|
|
Hi,
It depends if the variable has been declared public or not, take a look in the code if TextBox2 has been declared as public. I think you can use that
|
|
|
|
|
|
Hello all, hope all is well,
Here is a link to the complete application in question all zipped up, question below: Date Validator
Ok, I wrote a small windows form's app to use as a front end test harness for a simple little date validation class that I am working on. I need the date class for a web service that I am working on, and I needed a way to just test that class so I wrote this little front end app. My compiled app is only 9kb; small. When I run the app it takes up 10+ meg of memory to run; BIG. Now I am fairly new to C# and .NET, but to me that seems like a LOT of over head for such a small and simple app.
I was wondering if some of you more experienced developers out there could take a look and see what I can do to get that foot print down some. Also what are some ways that I can make the worker class (DateValidator.cs) of this run better. The project posted below has two main classes broken apart, one for the form part and one for the class that I hope to be able to reuse in other .Net apps.
1. frmDateInput.cs
2. DateValidator.cs
Here is another link to the complete application all zipped up: Date Validator
I would post the code from each class here but that would be a LOT to read through.
Thanks in advance,
Bill K.
|
|
|
|
|
I thought I would just post these each in their own post so that people can read them with out having to down load the source.
========================================
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace DateValidator
{
public class frmDateInput : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox txtDate;
private System.Windows.Forms.Label lblDateFormat;
private System.Windows.Forms.Button btnCheckDate;
private System.Windows.Forms.Label lblDateStatus;
private System.Windows.Forms.Label lblDateStatusTag;
private System.ComponentModel.Container components = null;
public frmDateInput()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.txtDate = new System.Windows.Forms.TextBox();
this.btnCheckDate = new System.Windows.Forms.Button();
this.lblDateFormat = new System.Windows.Forms.Label();
this.lblDateStatus = new System.Windows.Forms.Label();
this.lblDateStatusTag = new System.Windows.Forms.Label();
this.SuspendLayout();
this.txtDate.Location = new System.Drawing.Point(16, 17);
this.txtDate.Name = "txtDate";
this.txtDate.Size = new System.Drawing.Size(176, 20);
this.txtDate.TabIndex = 0;
this.txtDate.Text = "";
this.btnCheckDate.Location = new System.Drawing.Point(208, 16);
this.btnCheckDate.Name = "btnCheckDate";
this.btnCheckDate.Size = new System.Drawing.Size(96, 23);
this.btnCheckDate.TabIndex = 2;
this.btnCheckDate.Text = "Check Date";
this.btnCheckDate.Click += new System.EventHandler(this.btnCheckDate_Click);
this.lblDateFormat.Location = new System.Drawing.Point(16, 44);
this.lblDateFormat.Name = "lblDateFormat";
this.lblDateFormat.Size = new System.Drawing.Size(100, 16);
this.lblDateFormat.TabIndex = 3;
this.lblDateFormat.Text = "MM/DD/YYYY";
this.lblDateStatus.Location = new System.Drawing.Point(88, 72);
this.lblDateStatus.Name = "lblDateStatus";
this.lblDateStatus.Size = new System.Drawing.Size(216, 16);
this.lblDateStatus.TabIndex = 4;
this.lblDateStatusTag.Location = new System.Drawing.Point(16, 72);
this.lblDateStatusTag.Name = "lblDateStatusTag";
this.lblDateStatusTag.Size = new System.Drawing.Size(72, 16);
this.lblDateStatusTag.TabIndex = 5;
this.lblDateStatusTag.Text = "Date Status:";
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(320, 94);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.lblDateStatusTag,
this.lblDateStatus,
this.lblDateFormat,
this.btnCheckDate,
this.txtDate});
this.Name = "frmDateInput";
this.Text = "Date Validator";
this.ResumeLayout(false);
}
#endregion
[STAThread]
static void Main()
{
Application.Run(new frmDateInput());
}
private void btnCheckDate_Click(object sender, System.EventArgs e)
{
if(txtDate.Text != string.Empty)
{
int retStatus = DateValidator.parseDate(txtDate.Text);
switch(retStatus)
{
case 1:
lblDateStatus.Text = "This date is valid!";
break;
case 0:
lblDateStatus.Text = "This date is NOT valid, reason unknown!";
break;
case -1:
lblDateStatus.Text = "The month is not correct!";
break;
case -2:
lblDateStatus.Text = "The day is not correct!";
break;
case -3:
lblDateStatus.Text = "The year is not correct";
break;
case -4:
lblDateStatus.Text = "The date string tested was not complete!";
break;
}
}
else
{
MessageBox.Show("A date is required!", "Error!");
}
}
}
}
========================================
Thanks,
Bill K.
|
|
|
|