|
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.
|
|
|
|
|
Skynyrd wrote:
I cant seem to imagine any situation where a property isn't a viable solution
The issue is that I'm trying to create an OO solution in a way that doesn't use a property, so I can impliment a pattern without having to write a property, I can just add an attribute.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
|
How would that work ? I create an attribute, and it's called in the base class when the value changes, how ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
|
CG, I think your best choice is to simple use a property. That said, I would like to this you could perform some reflection magic along with the ILGenerator class to perform this (just a thought).
- Nick Parker My Blog | My Articles
|
|
|
|
|
Sounds interesting, do you have more info ? Yes, I could use a property, but as I said, I'm looking for another option.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I have a direct draw based application and i need to play in a part of the screen a macromedia flash(.swf) file.How can i do this? Is it possible?
i hoope someone can sand me some code...plz
plz send a response at :krutsch@gmail.com
13
|
|
|
|
|
take a look at COM Control Shockwave Flash Object.
U can add it to ur designer toolbox and put it anywhere in ur form as u would with any other control.
I think it will do what u need, but I dont have specific data on how to program against it. A quick google search should givue u info.
|
|
|
|
|
Hello,
I am developing a database application for a library system. I have teachers, students, and books. I have done programming in oop in C++/java. I know about classes, objects, heratance,multiple heritance and polymorpthom. But l am not sure how l could apply this to my database application in visual C#. I know that everything in C# is made up of classes and objects with the controls.
If l was to do this application in C++ or java, then my classes would be teacher, student, and book. Then the instance variable for the student would be things like IDNumber, Name, Address, phoneNo, and e-mail, etc. The instance methods would be addStudent, updateStudent, deleteStudent, etc.
But l am not sure how to apply this in Visual C++. Do developers in the real-world use classes and objects? Does anyone have a small example program that l could examine? Or is there any tutorals on the internet that shows you a step by step in developing a database application using classes and objects.
Thanks for your help,
Steve
|
|
|
|
|
steve_rm wrote:
But l am not sure how to apply this in Visual C++.
I assume you mean C#. These principles apply without change in C#. C# is virtually Java anyhow.
steve_rm wrote:
Do developers in the real-world use classes and objects?
I doubt there are many that don't use them every day.
steve_rm wrote:
Or is there any tutorals on the internet that shows you a step by step in developing a database application using classes and objects.
I'm sure there is, even here on CP. For starters, I tend to do all my data access through stored procedures, then I write a class full of static methods that call the procedures. That's my data layer, the rest of the code just calls it.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
U might want to take a look at DataSets and Schemas. It sounds like the editor's self generated strongly typed datasets based on ur DB schema would do you lots of good.
|
|
|
|
|
Here is what i have. I am creating an address book using C# and saving the info in an XML file. I wanna be able to write a last name in a text box and have the inforamtion about that contact to show up on the form( I don't wanna use a list box, just in case the list is long). I have been pulling my hair out with this for the past 2 weeks. I decided to give up and come here for help.
here is a sample of how things are stored in my XML file:
- <Contact ContactNumber="13">
<LastName>Lucio</FullName>
<FirstName>Brell</FirstName>
<PhoneNumber>222-222-2222</PhoneNumber>
<Email>brell@yahoo.com</Email>
<Street>2 two street</Street>
<City>twoCity</City>
<State>MD</State>
<ZipCode>22222</ZipCode>
<Country>USA</Country>
</Contact>
I guess the guess the ideal will be to have a process that will match the last name "Lucio" with the ContactNumber "13" when it is entered in the search textbox. And then have something to bring up the information stored in ContactNumber="13".
Well I just don't know how to code this part.
Any help would be greatly appriciated.
Thanks in Advance
McGrady
A NewBie in tha Block
|
|
|
|