|
I apologize for the assumption, from your post I wasn't sure you were actually using events.
I don't think you'll need static events, unless that's what you want to do. If B has an event, when A creates those instances it should be able to hook the new B instance's events to a method of it's own. Also on creation of the B instances, you can set them up as subscribers to events that A has.
Is this the kind of thing you're talking about? Or did I completely misunderstand your question?
class A {
public event EventHandler OnA;
public void Start() {
B b1 = new B(1);
b1.OnB += new EventHandler(CatchOnB);
OnA += new EventHandler(b1.CatchOnA);
B b2 = new B(2);
b2.OnB += new EventHandler(CatchOnB);
OnA += new EventHandler(b2.CatchOnA);
b1.DoStuff();
b2.DoStuff();
if (OnA != null) {
OnA(this, EventArgs.Empty);
}
}
private void CatchOnB(object sender, EventArgs e) {
Console.WriteLine("B{0} called me", ((B)sender).Id);
}
}
class B {
public event EventHandler OnB;
public int Id;
public B(int id) {
this.Id = id;
}
public void CatchOnA(object sender, EventArgs e) {
Console.WriteLine("A called B{0}", Id);
}
public void DoStuff() {
if (OnB != null) {
OnB(this, EventArgs.Empty);
}
}
}
|
|
|
|
|
Thank you, BoneSoft.
I had missed this post way back when, and only just saw it today. This answers my question nicely. I wish I had noticed it before.
Clive Pottinger
Victoria, BC
|
|
|
|
|
Sure thing. Hope it helps.
Visit BoneSoft.com for code generation tools (XML & XSD -> C#, VB, etc...) and some free developer tools as well.
|
|
|
|
|
A should register the events it wants to listen to on B when it creates them.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
cpotting wrote: so that B3 does not have to know about object A?
Yeah that's a very common problem in software design.
cpotting wrote: Can I call
There may be many things you can do, but likely a sub set of them that are considered best practice. You could do some studying of Software Design Patterns that would shed some light on this subject for you, if you wanted to.
led mike
|
|
|
|
|
have a report that contain at least 7 subreports. Each with their own datasource. I have set the subreports datasource to the correct datasource and on a few of them passed in parameters.
however, upon running it I noticed that the reports would show "SubReport cannot be shown". I made sure my parameters were being passed and its of the same type.
I googled and found a lot of examples that used the 'LocalReport_SubreportProcessing' event to populate the datasources for each subreport.
Is this the right way to go about it? I cannot find any good examples of how to populate a subreport. I need to justify putting the logic like this inside the ReportViewer form rather than someplace else.
Could someone please shed some light on this for me?
I am using VS 2005 C#, Sql 2k, on Windows Server 2003. I am using Reporting Services however the reports in my project are .rdlc files not .rdl they are inside my Windows Project not a Reporting Project...if this matters.
Any help asap would be greatly appreciated. Below is a small sample of how im using the event.
void LocalReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e)
{
if(ReportEmbeddedResource =="Desktop_Controller.Reports.Desktop_Controller.Reports.rptPatientInfo.rdlc")
{
System.Diagnostics.Debug.Write("SubReport being processed: " + e.ReportPath + "\r\n");
try
{
switch (e.ReportPath)
{
case "rsubPatientInfoReferred":
if (null == vwReferrals)
{
VwPatientInfoReferralsService vwSer = new VwPatientInfoReferralsService();
vwReferrals = vwSer.GetAll();
}
vwReferrals.Filter = "PatientNumber = '" + PatientNumber + "'";
e.DataSources.Add(new ReportDataSource("StVincent_Bariatrics_DomainModel_VwPatientInfoReferrals", vwReferrals));
break;
}
}
catch{}
}
}
Steve Welborn
Software Engineer
Inrange Consulting
modified on Friday, January 25, 2008 1:49:29 PM
|
|
|
|
|
Hello, I want to deploy a web service that exposes an Access database to clients, the database file is located in the App_Data folder in the service's folder.
The problem is that I have to set the security settings for that file manually using NTFS security tab in the properties window of the database file to allow the account "ASPNET" to write to the database.
Is there a way to do this during the setup process? I have wondered around the setup project I created for the web service and I had no clue on how to do this.
|
|
|
|
|
Wassim Mansour wrote: Is there a way to do this during the setup process?
Of course
Wassim Mansour wrote: I had no clue on how to do this.
If it is a Windows Installer check out Installsite.org[^]
led mike
|
|
|
|
|
On my form paint method i drew this ellipse but how can i make this circle transparent so if i put this ellipse on the top of another object it becomes transparent.
Graphics g = e.Graphics;
Rectangle r = new Rectangle();
r.Size = this.Bounds.Size;
GraphicsPath ca = new GraphicsPath();
ca.AddEllipse(r);
Region region = new Region(ca);
this.Region = region;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
g.DrawEllipse(new Pen(Brushes.Red), Rectangle.Inflate(r, -1, -1));
g.FillEllipse(Brushes.AntiqueWhite, Rectangle.Inflate(r, -3, -3));
|
|
|
|
|
I don't think the 2D Drawing methods are object aware and you would likely have to create your own code, which would be slow.
One thing I do know, however, is that AntiAlias should not be applied until after the transparency or you will get a glow.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
but What do i have to create my own.....Could you provide me any helpful link or a code snap plz
|
|
|
|
|
If you want to draw your own then you need to draw the lines your self and for each pixel determine if it is within the bounds of another polygon. Use the even/off fill algorithm for efficient filling.
One other option is to define regions and XOR the regions before drawing to the bitmap.
As for links I have none and would search the web to find them so ...
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
Hi every one,
I m working on a client server application which communicates through remoting.
Now what i want is when client send request to server and after the request execution a notifier should popup on the client task bar to notify the successful execution of the request.
|
|
|
|
|
You don't say what type of app so I'll assume WinForms - you'll need to get your server to send a confirmation message back to the client to say it suceeded and use a NotifyIcon in the client app to display the message.
|
|
|
|
|
|
Hi,
In .NET, I found this term "Dirty" in so many places like
_viewState.SetDirty(true);
myObject.RegisterForDirtyRange(var1, out var2);
etc. My assumption was like this. If I implement some logic with very hardcoded core language statements which is almost closed to machine language or very lower level language, then that code is termed by DIRTY code. But what is other special meaning of Dirty in .NET ? I searched in Google and millions of titles shows up with the word Dirty which does not provide me the basic answer, rather, something else. So, would you please give me a clue !!
thank you.
|
|
|
|
|
Normally it means the data has changed. e.g. If you loaded a text file and then edited it, the document is now 'Dirty' until saved.
|
|
|
|
|
Thank you very much. Now I got it.
|
|
|
|
|
Hello,
Am trying to bind data.This is my code.Is there any problem with my code since it does not seem to work.
Take your time.
Thanking You
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace TestDb
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnInsert_Click(object sender, EventArgs e)
{
OleDbConnection conObj = new OleDbConnection();
conObj.ConnectionString=@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\j\My Documents\MyDb.mdb";
conObj.Open();
OleDbCommand cmdObj = new OleDbCommand();
cmdObj.CommandText = "Insert into MyTable(Name) values ('" + txtName.Text + "')";
cmdObj.Connection = conObj;
cmdObj.ExecuteNonQuery();
txtName.Clear();
}
private void btnBind_Click(object sender, EventArgs e)
{
OleDbConnection conObj = new OleDbConnection();
conObj.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\j\My Documents\MyDb.mdb";
conObj.Open();
OleDbCommand cmdObj = new OleDbCommand();
cmdObj.CommandText = "select Name from MyTable";
DataSet ds = new DataSet();
cmdObj.Connection = conObj;
OleDbDataAdapter adapObj = new OleDbDataAdapter();
adapObj.SelectCommand = cmdObj;
adapObj.Fill(ds);
}
}
}
|
|
|
|
|
Trustapple wrote: Hello,
Am trying to bind data.This is my code.Is there any problem with my code since it does not seem to work.
Take your time.
Thanking You
I didn't look at the code you provided, because you weren't specific. When you say "it doesn't work," you need to be more specific. How does it not work? Does it get errors on build, a run-time exception, or does it just sit there and do nothing? Have you tried setting breakpoints to see what your code is doing?
I'm going to become rich when I create a device that allows me to punch people in the face over the internet.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
|
|
|
|
|
In future posts, please use the <code></code> tags to make your code easier to read
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Paul Conrad wrote: please use the <code></code> tags
Absolutely not. Don't use CODE tags for multi-line stuff, they are for single-line things only.
Multi-line code should be in PRE tags which preserves formatting. With two caveats:
- empty lines disappear, so add a space tot them
- less-than signs followed by a letter will be eaten by the HTML deamon, therefore replace < by <
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
That's right, my bad. I remember we did a big investigation on this last summer I thought it was pre and code together.
"What's your question? All I see is some deranged, half-assed looking run-on sentence. Where are you having problems?" - Justin Perez
|
|
|
|
|
someone should sticky this..I keep forgetting.
Steve Welborn
Software Engineer
Inrange Consulting
|
|
|
|
|
Look at Luc's article he did on the topic.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|