|
try{}catch{} wont catch any exceptions as I learnt only a few days back. Although this is acceptable to the compiler, it wont catch any exceptions unless specified.
Hope its the problem you having. Your code screwd up the formatting.
|
|
|
|
|
there is nothing to try catch as far as i'm aware, the code seems to be working but i'd don't understand why i can do X = Y and then have X.col diferent to Y.col hope that clears up any misunderstandings
and as i've got you email i'll send a copy of the code if you can't help for what ever reason i thank you for your time
|
|
|
|
|
I suggest u make Galaxy also inherit from MarshalByRefObject.
|
|
|
|
|
That was the first thing i tried but that causes a
An unhandled exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll
Additional information: Because of security restrictions, the type System.Runtime.Remoting.ObjRef cannot be accessed.
and i don't know how to get round it.
|
|
|
|
|
this
for(int i=0;itry{
GetPlayer(i).Gal.Systems = this.Gal.Systems;
}
catch{
players.RemoveAt(i);
i--;
}
}
used to be
for(int i=0;itry{
GetPlayer(i).Gal = this.Gal;
}
catch{
players.RemoveAt(i);
i--;
}
}
but i kept geting security exceptions saying the objref was unavalable and the cahnge seemed to be the only thing that fixed it, though i don't see why there was a prob in the first place as gal is an instance of
[Serializable]
public class Galaxy{
...
}
which i thought dealt with reading it for transmission
|
|
|
|
|
Hi,
I created a new class(AdvListViewItem) that inherits from the ListViewItem. This class replaces certain base class methods/properties with identical methods/properties except that the new methods/properties fire an event when they are run. However, when accessing the new method/property through the listview (ie. listview1.SelectedItems[0].Font), the methods/properties of the base listviewitem are run.
Do I have to replace the SelectedItemCollection also for my code to work?
|
|
|
|
|
You should probably override CreateControlCOllection or something like that. Look at the protected methods.
|
|
|
|
|
I realized that when I was adding the AdvListViewItem to the listview through the Items property, it was casting the AdvListViewItem to the standard ListViewItem. So I want to replace the ListViewItemCollection class represented by the Items property with a derived one that replaces the Add method with one that accepts an AdvListViewItem. The problem is I don't know how the collection stores the internal ListViewItem objects.
How do I add to the internal collection, or do I have to recreate the class completely (including my own collection)? The ControlCollection does not allow me to add listviewitems to it.
|
|
|
|
|
Anonymous wrote:
The ControlCollection does not allow me to add listviewitems to it.
Of course it won't - that's only for Control instances, which ListViewItem s are not.
You could always add your derivative ListViewItem s to the base class's Items properties, using base.Items and calling the appropriate actions. Since you hide that member, your Items collection property will be called only when referencing your type by its actual Type (and not ListView ), but nothing is preventing you from using the base class's collection property to store the items. After all, your derivative class is still a ListViewItem a la polymorphism.
Search CodeProject. There are some articles that discuss how to do this, as well as some examples I remember seeing on MSDN[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi
Is there any way (C# or API) to get the icon associated with a given file type?
I've looked to SHGetFileInfo but this only works if I give a path for an existing file.
Thanks
|
|
|
|
|
You can access the HKEY_CLASSES_ROOT/<file type="">/DefaultIcon registry key and retrieve the icon from the file listed there.
There is probably a better way but this is what I know currently.
|
|
|
|
|
Didn't show up properly:
HKEY_CLASSES_ROOT/<file type>/DefaultIcon
|
|
|
|
|
Hi,
Thanks for your awnser!
I've tried that already but it doesn't seems to be the right way to do that.
There are a lot of entries that don't have the DefaultIcon entry but still have an icon associated with it.
|
|
|
|
|
|
I downloaded some projects but it didnot work because of
(usin system.win.forms) which doesnot exists....can u tell me how to make my application recognizes this directive?
|
|
|
|
|
try using System.Windows.Forms;
To those who didn't make it, we will remember you. To those who did is back. - Megan Forbes in Black FridayAnother Post by NnamdiOnyeyiri
|
|
|
|
|
also make sure the references include the system.windows.forms dll normaly located at
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Windows.Forms.dll
|
|
|
|
|
is there any method to get windows and system directory in c# ?
and how to get the version of windows ?
thanks .... !
|
|
|
|
|
kendao wrote:
is there any method to get windows and system directory in c# ?
Environment.SystemDirectory
kendao wrote:
how to get the version of windows ?
Environment.Version
Mazy
"I think that only daring speculation can lead us further and not accumulation of facts." - Albert Einstein
|
|
|
|
|
Hi,
Using the VS IDE, I have a Form which loads and manages a DataSet. The form contains UserControls that need to references the same DataSet. Using the IDE, while designing the UserControl, how do I reference the DataSet in the parent Form?
As an interim solution I drag/drop another DataSet onto the UserControl and do all my object DataBindings to that DataSet. But, after the initialization of the UserControl I have to modify each objects DataBindings to reference the DataSet in the Parent Form.
Is there a better(correct) way of doing it?
|
|
|
|
|
The best way is to have the child controls reference the DataSet from the parent form (defined as Form1 in this example). Just cast the Parent property to Form1 and get the reference to the DataSet that you should define as a public or internal property:
public class Form1 : Form
{
private DataSet dataSource;
public DataSet DataSource
{
get { return this.dataSource; }
}
}
public class UserControl1 : UserControl
{
private void BindMe()
{
SomeMethodThatBindsData(((Form1)Parent).DataSource);
}
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi Heath
Thankyou for your response, I do appreciate it.
Your example is basically what the result should be, just I want to do it with the IDE. I have many UserConstrols on various forms and it would require typing the DataBinding for each object, which I have actually done using an enumaration over all controls over all DataBindings.
If I could have replaced the 'DataSet ds = new DataSet()' in the 'InitializeComponent()' function with a reference to the DataSet it would have solved the problem or if I could have overloaded the 'new' keyword for a DataSet, which I don't think I is possible, or is it?
Yours Sincerely
Festus
|
|
|
|
|
You can't override the new operator, but you can create a ContextBoundObject with its own RealProxy derivative that returns a singleton, but this is more work that necessary and since the DataSet would need to be marshalled across boundaries, it would degrade performance.
Relying on the IDE is poor programming. It can't do everything. You can, however, use the DataBindings property and type in the expression if you like, but you'll still need to cast Parent to the form in order to access the variable you'll need since Form doesn't have a property defined for whatever property returns your DataSet .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i want to abtain remote screen capture on the pc in LAN.
i was suggested to transmit the changed parts only to save the bandwidth.
so i divide the screen into 10*10 parts. and now , i need to display the
remote screen on my own form. my method is use this:
Graphics c = this.createGraphics();
c.drawImage(imageparts,xcoodinary,ycoodinary);// imageparts is ONE part
// of the screen (1/100)
whenever i receive a imageparts, i use the code above to draw the changed
screen parts on a FORM. the code seems to work well.In the first time,i
should call this code 100 times to get the original screen.after then , i
could only call this code several times.
but now ,when the FORM is changed or covered by other windows , with the
repaint result ,the image disappeared or changed into a wrong display.
So i should put the code above into OnPaint method. but the code above only
redraws the changed parts of the remote screen, the others disappeared.
How can i redraw the previous unchanged image already on the FORM ? OR are
there other methods to solve this problem ?
THX!
|
|
|
|
|
The is a C# implemetation of VNC on SourceForge.
|
|
|
|