|
Class1 is doing the job with controls which it doesn't own - a far from ideal situation. It's a quick and dirty solution, but I advise you to avoid it.
An event driven system is much better and not difficult. Simple example below:
using System;
public class Class1
{
public event EventHandler<MyEventArgs> MyEvent;
public void PerformMyMethod(string item)
{
OnMyEvent(new MyEventArgs(item));
}
protected virtual void OnMyEvent(MyEventArgs e)
{
EventHandler<MyEventArgs> eh = MyEvent;
if (eh != null)
eh(this, e);
}
}
public class MyEventArgs : EventArgs
{
private string _MyString;
public MyEventArgs(string myString)
{
_MyString = myString;
}
public String MyString
{
get { return _MyString; }
}
}
using System;
using System.Windows.Forms;
public partial class Form1 : Form
{
Class1 class1;
public Form1()
{
InitializeComponent();
class1 = new Class1();
class1.MyEvent += new EventHandler<MyEventArgs>(class1_MyEvent);
class1.PerformMyMethod("Hello World");
}
void class1_MyEvent(object sender, MyEventArgs e)
{
MessageBox.Show(string.Format(
"{0} from {1}!", e.MyString, sender));
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Thanks Deve...
I am totally new in C# but I have already develop a software for my office :P
With those poor logics. Now I am trying to read more and use best solution.
I am trying to understand your code.
Thanks for your effort.
|
|
|
|
|
Have a look at my article Events Made Simple[^] - it explains each line and builds step by step.
If you need more clarification, feel free to post back here
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hi,
does anybody know of any information that suggests which version of the .NET framework is most popular?
We are looking to develop an application on .NET 3.5, but which version is most commonly installed?
thanks
Bluetooth Marketing
Bluetooth Advertising
|
|
|
|
|
|
According to my knowledge Framework version 2.0 is the best and stable. After all version 3.0 and 3.5 are extension of 2.0.
A DATAPOST COMPUTER CENTRE
(K.V Prajapati)
|
|
|
|
|
Be that as it may, how many systems have those but not 1.1?
|
|
|
|
|
Of course you are right. I meant the popular one.
A DATAPOST COMPUTER CENTRE
(K.V Prajapati)
|
|
|
|
|
Unless you need the latest new fangled whoopy doopy stuff, stick with 2.0 as that's a fair bet IMO.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
<blockquote class="FQ"><div class="FQA">DaveyM69 wrote:</div>stick with 2.0 as that's a fair bet</blockquote>
that was our thought, but does the proof that i'm looking for actually exist?
Bluetooth Marketing
Bluetooth Advertising
|
|
|
|
|
3.5 has a bunch of needless crap in it. (Linq, WPF, etc.)
The only worthwhile member of 3.5 is System.Collections.Generic.HashSet<T> , and even that's not very usable.
|
|
|
|
|
hi guys i am a informatic student and i am trying to bind php and c# with webservice (nusoap. so i have this php script:
<?
//incluimos la clase nusoap.php
require_once('lib/nusoap.php');
//declaramos el namespace
$ns="http://www.dominio.com/servidor.php";
//Setup del WSDL
$server = new soap_server();
$server->configureWSDL('webservice',$ns);
$server->wsdl->schemaTargetNamespace=$ns;
//Definimos la estructura de cada registro
$server->wsdl->addComplexType(
'registro',
'complexType',
'struct',
'all',
'',
array(
'nick'=>array('name' => 'nick', 'type' => 'xsd:string'),
'pass'=>array('name' => 'pass', 'type' => 'xsd:string'),
'telefono'=>array('name' => 'telefono', 'type' => 'xsd:string')
)
);
//Definimos la estructura de la matriz que usa los registros
$server->wsdl->addComplexType('estructura', 'complexType', 'array', '',
'SOAP-ENC:Array', array(),
array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:registro[]')),
'tns:registro');
//Registramos el método para devolver los valores de la tabla, en este caso es una consulta simple, mediante la cual se devuelven todos los registros de la tabla sin recibir ningún dato del cliente:
$server->register('obtenerdatos',array(),array('return'=>'tns:estructura')); //Definimos que lo que vamos a retornar es una matriz con la estructura "estructura
function obtenerdatos(){
$link = mysql_connect("localhost","root","213141");
mysql_select_db("ws");
$ssql_=mysql_query("select nick, pass, telefono from usuarios",$link)or die(mysql_error());
$numrows=mysql_num_rows ($ssql_);
$tabla=array();
for($x = 0; $x < $numrows; $x++) {
$tabla[]= mysql_fetch_array($ssql_);
}
return $tabla;
}
//llamamos al método service de la clase nusoap
$server->service($HTTP_RAW_POST_DATA);
?>
but i don't know how to get the data in c#, please help me.
It is too importan for me.
thanks
jahc the best
|
|
|
|
|
the class Timer is marvelous ... but asynchrone !!!
Can I don the same, without use horrible 'Sleep', in C#, but without the use of the API windows ??
Thanks a lot.
Bernard
|
|
|
|
|
either you wait some time (i.e. Thread.Sleep) or you organize a timer event.
What else could you possibly want?
FYI:
- don't call Sleep on the GUI thread;
- for delayed GUI stuff, use a System.Windows.Forms.Timer, that one ticks on the GUI thread.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I would like to build a custom control that would be exactly like the CStatic and CRectTracker are combined in MS Paint. What controls can be used to mimic this in .NET?
|
|
|
|
|
So I'm trying to workout a Chance on how often you would Die in a game with a push and every push had a 6% death with the Code I'm trying to use is
Death1 = (1 - Death) ^ HKill;
Yet you aren't allowed to use ^ on 'decimal' and 'decimal'.
I need to use decimals as 'int' wouldn't give a a true enough number to work with, any one know a formula that would do the above operation?
|
|
|
|
|
Hi,
From the MSDN documentation: "Binary ^ operators are predefined for the integral types and bool. For integral types, ^ computes the bitwise exclusive-OR of its operands. For bool operands, ^ computes the logical exclusive-or of its operands; that is, the result is true if and only if exactly one of its operands is true."
Exponentiation doesn't have its own operator; however there is Math.Pow (which works with doubles).
Decimals are used for quantities that need to be exact (i.e. currency amounts), not for dying game players.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
will look into the Math.Pow, but the Answer that the Calculator needs to come up with it 17.89% can't get that with int but thanks.
Works, Thank mate.
modified on Sunday, May 17, 2009 5:57 PM
|
|
|
|
|
|
hi all
I have a database with multiple tables
I want to fill my DataSet.
must I use DataAdapter for each table in my database ?
is this the best way ?
|
|
|
|
|
Click[^]
My failometer is detecting vast quantities of FAIL!
"Its SQL - hardly programming..." (Caslen)
|
|
|
|
|
Best not to use DataSets and DataAdapters at all.
|
|
|
|
|
|
Take a copy of where the inside rectangle should go. That'll give you the image in the centre. Draw the outside rectangle with the fill colour. Draw the copy of the image at the original co-ordinates of the inside rectangle. I don't really know how to explain this better without going into a fairly terse explanation, but that's the basic idea
|
|
|
|
|
or fill four rectangles, one for each side of the overall rectangle.
or paint one rectangular outline with a wide pen.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|