|
Thank you. I do not understand enough of interfaces to get my solution working yet, but found an interesting working solution at http://www.thecodeproject.com/csharp/SnapIn.asp with your pointer. It is not mdi, but easy adaptable. I'll spend some time on understanding that.
regards,
Stefan.
|
|
|
|
|
I have a picturebox control that I'm using the imagelist to draw one of two different images on. they're place in one of 24 different positions. the images draw great and look fine. The problem is if another window overlaps my picturebox, the images disappear. I'm new to C#, and I'm wondering should I be handling the form's paint event, or something different?
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
try this in every handling for proposes problems this.refresh()
ByMindOnlyYouCanDoIt
|
|
|
|
|
I've made a class (CDot) that takes as its constructor's parameters two int's and an enum value that is defined inside the class. In my code when i try to make a new instance of the class, in the next call to add this to an arraylist, it crashes telling me "object reference not set to an instance of an object". I step through the code and put the object reference in the watch window, and sure enough, its values are all 0's. Any suggestions?
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
Hi again!
I've made a class (CDot) that takes as its constructor's parameters two int's and an enum value that is defined inside the class.
First, I would recommend not to define the enumeration inside the class. Well, it isn't as bad as a class defined inside a class but I'd still say it's confusing enough.
In my code when i try to make a new instance of the class, in the next call to add this to an arraylist, it crashes telling me "object reference not set to an instance of an object".
Would you mind sending an excerpt of your code?
Best regards
Dennis
|
|
|
|
|
It wasn't my class, it was the arraylist object that I didn't use 'new' on that was causing the problem. thanks.
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
Hi,
i am using .NET Compact Framework with Visual Studio C# .NET 2003 for a little PocketPC application.
I want to use the Clipboard but it seems to be not available in .NET CF.
Also i cannot find the method .Copy() within System.Windows.Forms.TextBox.
Does anybody has an idea?
Thanks in advance.
Greetings.
Matthias Glemser
|
|
|
|
|
MSDN has this example code:
// C#
private void button1_Click(object sender, System.EventArgs e)
{
// Create a new instance of the DataObject interface.
IDataObject data = Clipboard.GetDataObject();
// If the data is text, then set the text of the
// TextBox to the text in the Clipboard.
if (data.GetDataPresent(DataFormats.Text))
textBox1.Text = data.GetData(DataFormats.Text).ToString();
}
// C#
private void button1_Click(object sender, System.EventArgs e)
{
Clipboard.SetDataObject(textBox1.Text);
}
Apparently, "Clipboard" is not in the .NET-CF, so maybe the second one wont work. I have no way to try this.
As for Copy() - According to my VS.NET-Help, there is no method "Copy()" within S.W.F.TextBox or S.W.F.RichTextBox.
Cheers
Sid
|
|
|
|
|
Hi Sid,
thanks for your reply.
Meanwhile I also found, that "Clipboard" and .Copy() is not available in the Compact Framework.
But i found a great solution at http://www.opennetcf.org. Have a look.
Matthias
|
|
|
|
|
Hi,
The AssemblyInfo.cs file contains attributes, such as AssemblyVersion, which I want to use programatically, as in an About dialog. I have looked at the AssemblyVersionAttribute class, but I can't find any examples showing how to use it. Any help on this would be greatly appreciated.
Thanks,
Royce
|
|
|
|
|
Use System.Window.Forms.Application.ProductVersion
|
|
|
|
|
Hi Royce!
The AssemblyInfo.cs file contains attributes, such as AssemblyVersion, which I want to use programatically, as in an About dialog.
I suggest you should use the classes in the System.Reflection namespace rather than the ones from System.Windows.Forms because retrieving metadata from assemblies is exactly what the reflection classes were made for.
Version MyVersion = Assembly.GetExecutingAssembly().GetName().Version;
MessageBox.Show(MyVersion.ToString());
Best regards
Dennis
|
|
|
|
|
More generically (i.e. if you plan to use custom attributes or there is a possibility that you will be inspecting third party assemblies that may do so), you could do something like this:
object[] attribs = Assembly.GetExecutingAssembly().GetCustomAttributes(true);
That will return all of the custom attributes applied to the executing assembly either directly or through inheritance.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
I've added a listview to my windows form. Then through the properties pane, I've added two images to the collection. However, it crashes on me when I call the imageList1.Draw() method saying that the index is out of bounds whether I use an index of 0 or 1. When I click my test button to get the images.Count, it returns 0. does anyone know what the heck is going on? Thanks in advance.
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
Sorry, I set the instance of my listview to a 'new' one again in my form load event, so this was a whole new instance of the control, (with no images).
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
I'm using a listview in details mode, and I'd like to be able to hide the header columns. Is there a way to do this?
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
Hi BlackDice!
I'm using a listview in details mode, and I'd like to be able to hide the header columns. Is there a way to do this?
Just set the ListView.HeaderStyle [^] property to ColumnHeaderStyle.None [^].
Best regards
Dennis
|
|
|
|
|
Perfect!!! thanks
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
How can I set up a variable so that a method is called when it's value changes ? I know a property can do this, but I want to do it at the type level, i.e. I want to do this:
class MyClass
{
public int MyInt
}
..
myClass.MyInt = 5; // Some code somewhere is called to tell me this value has changed
The example is over simplistic, making a property seem a viable solution, when it is not. Any ideas ? If C# had operator=, I'd be set, but it doesn't.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Christian Graus wrote:
The example is over simplistic, making a property seem a viable solution, when it is not. Any ideas ?
I'd never make a member variable (field) public. I'd always expose the values through a property. Which, as you say, can invoke some method (or fire an event) when the value changes.
Do you want to know more?
|
|
|
|
|
Sure, in theory. In practice, I think it idiotic to write code like this
private int _myInt; // Oh, cool, look how OO my code is
public int MyInt
{
get...
set...
}
The net result is the same.
In this case though, it's not my intetion to make the variable public, I just don't want the property part of the code to be what notices that the value has changed.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Christian Graus wrote:
In this case though, it's not my intetion to make the variable public, I just don't want the property part of the code to be what notices that the value has changed.
So, you just want to add some protection from developers setting the variable without some other thing being triggered at the same time. And you can't necessarily do that with a member variable because, even if it is private or protected it is still accessible directly be code in the class (or, in the case of protected, but derived classes also).
You know, years ago I wanted to do the same thing because I didn't trust other developers to respect my code. In the end I just had to live with the idea that other developers tend to be reasonable sane people and if you comment the member variable telling people to access it trough the property (or some particular method) they will generally do that.
With XML comments it makes it easier because (when intellisense isn't broken) you can put in the <summary> tag some text that will appear in the tooltip so they know to use the property.
Christian Graus wrote:
In practice, I think it idiotic to write code like this [code omitted for brevity]
It is how the language works. Get over it.
Do you want to know more?
|
|
|
|
|
Colin Angus Mackay wrote:
years ago I wanted to do the same thing because I didn't trust other developers to respect my code
That is not remotely part of my thought processes.
Colin Angus Mackay wrote:
It is how the language works. Get over it.
No, the language does NOT force the construct where a private variable can be got and set by a public dual property.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Christian Graus wrote:
the language does NOT force the construct where a private variable can be got and set by a public dual property.
I know you can't force a private member variable to be accessed only through properties (public or otherwise) - Or have I misinterpreted something?
Do you want to know more?
|
|
|
|
|
<quote>The example is over simplistic, making a property seem a viable solution, when it is not
I cant seem to imagine any situation where a property isn't a viable solution
a get/set property is exactly what u ar looking for...an internal variable to which u can hook any validation/trigger when its value changes.
|
|
|
|