|
In your example, it looks to me like you get all the inconvieniences of separation with none of the benefit. In particular, there is still heavy dependencies between the two classes and neither can live without the other. So what's the point?
The best reason to separate is to make both classes simpler: a click event may make some other controls invisible and set a property in the controller class. The controller changes state and fires a bind method on the form. Now, you can easily test the controller and the form is simpler too.
Philip Nelson
|
|
|
|
|
Hi!
I'm developing an application that uses remoting. I used to use the .config file and RemotingConfiguration.Configure() to configure my server, but now I'm asked to save everithing on the registry. I've been able to migrate everything but the custom error attribute in the .config file. I have written my own Exception (which inherits from System.Exception). It is serializable and works great when I add the <customerror mode="Off"> in the .config file, but when I register everything programatically I get an exception in the client asking me to add that tag. Is there any way to do that by code?
Thanks in advance,
Matias
PS: if needed I can post the server code.
|
|
|
|
|
I'm having the same problem. Did you ever get an answer to this?
C LaMorticella
Client Instant Access
|
|
|
|
|
I created a class that inherits from the RichTextBox control. I need to do some custom drawing on the RichTextBox, so I override the paint event and do the custom drawing:
protected override void OnPaint(PaintEventArgs e)
{
// draw normally
base.OnPaint (e);
// add our custom border
ControlPaint.DrawBorder(e.Graphics, e.ClipRectangle, Color.Black, ButtonBorderStyle.Solid);
}
Simple enough, right? Well, when I run the app, every time I enter text into the control, the custom drawing I did gets cleared. Why is that? Is there a way around this?
The graveyards are filled with indispensible men.
|
|
|
|
|
Instead of using e.ClipRectangle, create a new rectangle with the size and position of e.ClipRectangle...
Free your mind...
|
|
|
|
|
I think I've found a bug in the XML documentation's integration with Intellisense. Here's the situation:
I have a class library that has a class with an overloaded indexer.
<br />
namespace myClassLibrary<br />
{<br />
class someClass<br />
{<br />
...<br />
public object this[int index]<br />
{<br />
...<br />
}<br />
<br />
public object this[string test]<br />
{<br />
...<br />
}<br />
}<br />
}<br />
All seems well and good, an overloaded indexer is no problem. If I begin typing the indexer in Visual Studio 2k3, Intellisense will rightly pop up and begin describing it. However, this is a class library and is used in other projects. If I begin typing the indexer for this class in a seperate project that uses this library, Intellisense shows no documentation for either indexer. Has anyone else seen this?
The graveyards are filled with indispensible men.
|
|
|
|
|
Jeez thats terrible! How about generating the XML doc file and placing that in the same directory as the assembly.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
No need for sarcasm. The xml file has been copied to the same folder as the assembly when used in other projects. Intellisense works fine for methods and properties in the project that's using the xml-documented class lib, with the exception of overloaded indexers.
The graveyards are filled with indispensible men.
|
|
|
|
|
I need to time how long certain methods are taking to run to a very fine level. Too fine for using DateTime and TimeSpan. Does anyone know of any tools that i can use to analyse which methods are bottlenecks?
Thanks
|
|
|
|
|
Try a profiler like ANTS. Or use interop to query the performance counter.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
I'm working on the same thing right now. System.Diagnostics provides access to the performance counters. That's all I can since I just looked at ten seconds ago.
When all else fails, there's always delusion.
- Conan O'Brien
|
|
|
|
|
It's exceedingly primitive, but combinations of System.Debug.Trace.WriteLines in conjunction with calls to System.Environment.TickCount have always served me well...just grab the tickcount into a long variable at the beginning of a method, and difference it with the current tickcount at the end of the method, then dump the output to the trace.
Jeremy Kimball
|
|
|
|
|
|
|
Ive downloaded this sample prg trying to get started with C# and directsound
http://www.c-sharpcorner.com/Code/2003/Jan/DotNetPiano.zip
Ive installed DX runtime 9.0 and SDK
I use MS V .NET 2003
I can see that .NET does not recognize the DX installation. It simply cannot reference the DX libraries.
How can I make this work?
|
|
|
|
|
The only way I got it to work was copying the DX9 assemblies out of the GAC and referencing from there. Of course, Windows Explorer doesn't allow copying out of the GAC; I had to use the command line to do it. :P
The graveyards are filled with indispensible men.
|
|
|
|
|
I have a combobox and I can't get it to display the selected value when i load my form :
I am manually populating the combobox rather than using comboBoxCFMName.DataBindings.Add
Saving works fine i.e. if I select a value from the combobox, everything will save back to the database but when the form is refreshed, the combobox doesn't display the value from the database. I have tried manually setting the combobox.SelectedValue, combobox.SelectedIndex and even combobox.Text (even a refresh), but none of them affect the value displayed in the combobox - it still displays the first value in its datasource. I have pasted the code below ...
/*-----------------------------------------------------------------------------------------------*/
dataViewRE.Table = DataSet.RE;
comboBoxName.DataSource = DataSet.CFM;
comboBoxName.DisplayMember = "Name";
comboBoxName.ValueMember = "ID";
if (dataViewRE.Count > 0)
{
comboBoxName.SelectedValue = dataViewRE[0].Row["ref_Name"].ToString();
// actual text that will be visible to the user of the combobox
string refName = DataSet.CFM.Select("ID = '" + dataViewRE[0].Row["ref_Name"].ToString() + "'")[0].ItemArray[1].ToString();
// index of the location at which the displayed text is stored in the combobox list
comboBoxName.SelectedIndex = comboBoxName.FindStringExact(refName);
// set the text of the combobox to the string to be displayed
comboBoxName.Text = refName;
comboBoxName.Refresh();
}
/*-----------------------------------------------------------------------------------------------*/
Any help appreciated ...
Thanks
Eco
|
|
|
|
|
I had a similar issue with the DropDownList and was able to set the SelectedIndex in the PreRender for the control.
I hope this helps.
|
|
|
|
|
Hello,
lets assume i have a filled ArrayList and want to print the content on a printer. How do i do this ?
Thank you for your assistance
Regards,
Peter
|
|
|
|
|
It depends on what you filled the ArrayList with. Do you want to print Strings?
//get printer settings
PrintDialog dlg = new PrintDialog();
dlg.Document = new PrintDocument();
dlg.Document.PrintPage += new PrintPageEventHandler( YourPrintMethod );
if(dlg.ShowDialog() == DialogResult.OK){
//start printing
dlg.Document.Print();
}
private void YourPrintMethod(object sender, PrintPageEventArgs e){
//loop through the array and print the objects
foreach(object obj in yourList){
e.Graphics.DrawString(...); //draw the object
}
}
|
|
|
|
|
Hello Corinna,
thank you for your help. Yes, i want print strings.
What do you mean with the three dots in
e.Graphics.DrawString(...); ???
Regards,
Peter
|
|
|
|
|
Graphics.DrawString is overloaded, there can be different parameter lists.
This is the easiest one:
SolidBrush brush = new SolidBrush(Color.black);
int verticalPosition = 0;
foreach(String s in yourList){
verticalPosition += this.Font.Height + 5;
e.Graphics.DrawString(s, this.Font, brush, 10, verticalPosition);
}
|
|
|
|
|
Hi Corinna,
thank you very much, this works fine.
Regards,
Peter
|
|
|
|
|
i am a C++ coder who recently made the conversion to C# (with which i am very pleased)
and yes i get it the list and and array list and all of that stuff is under System.Collections but i want to know if there is anway to make them return anything other than object
for instance if i have a multi level vector... er arraylist how can i make it so that i can say:
fu[i].bar[j].symbol = 6;
ok its not a real example but it is something that i would like to be able to do
i played with the get type function since it will return something's original type (before casting to say object) but it requiers a ';' after it so that didn't work (example of what i hoped would work ...
get {return (array_name[index].getType())[index];}
...)
but anyway if anyone has ideas feel free to share
Hope is denial of reality
-Raistlin Majere
Your ticket to the future is always blank
-Vash, Trigun
Once the picture is crumpled up it can't be perfect again
-Forgotten, Linkin Park
|
|
|
|
|
vylkier wrote:
but i want to know if there is anway to make them return anything other than object
Just create a new collection class inherited from CollectionBase, and set its method data types to the data type you want.
vylkier wrote:
for instance if i have a multi level vector... er arraylist how can i make it so that i can say:
fu[i].bar[j].symbol = 6;
ok its not a real example but it is something that i would like to be able to do
Hmm... I don't quite understand what you're trying to do here... are you wanting to be able to access the object through its own type rather than through the object type? If so, then the method above will work well for this.
vylkier wrote:
i played with the get type function since it will return something's original type (before casting to say object) but it requiers a ';' after it so that didn't work (example of what i hoped would work ...
get {return (array_name[index].getType())[index];}
...)
Hmm... that should be GetType() not getType() . Other than that, it should work, except what's that extra ')' for?
|
|
|
|