|
that is the normal behavior: the pen moves the way you ask it to move; when its size
exceeds one, it will hit some pixels before and after the intended trajectory since
a pen by default has a circular shape. I guess you can modify both the pen characteristics
and the way lines are drawn though, if you really need to.
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.
|
|
|
|
|
Thanks Luc,
Setting EndCap and StartCap to LineCap.Square solved it.
Kees
|
|
|
|
|
Reflection is cool, but geez it can be hard to get it to do some things. I want to enumerate all form controls on a user control that inherits from another user control which also has controls on it. Here's some sample code.
UserC in this sample is the user control which inherits from another user control.
Dim BindingFlags As Integer = Reflection.BindingFlags.Instance _
Or Reflection.BindingFlags.Public Or _
Reflection.BindingFlags.NonPublic
For Each fi As System.Reflection.FieldInfo In UserC.GetType.GetFields(BindingFlags)
Dim obj As Object = fi.GetValue(UserC)
If obj IsNot Nothing Then
Try
obj.Name()
Catch ex As Exception
End Try
End If
Next
This will list all the form controls on the UserC class designer but not the class it inherits from. You can see them all when debugging. What gives?
|
|
|
|
|
Hi, can't you just iterate through the userControl.Controls collection to get what you want? using your example you'll get all the fields in control UserC, not just the ones created by the designer. Or, you could try adding FlattenHierarchy to your binding flags (inherited fields must be protected, not private). Or you could write a recursive loop that examines the .BaseType fields of UserC.GetType()
HTH, Rob
"An eye for an eye only ends up making the whole world blind"
|
|
|
|
|
I was staying away from userControl.Controls so I would not have to recursively loop through container controls (a group box will appear in the .Controls but you have to walk through it's controls to get all the textboxes and such). I did try FlattenHierarchy and it didn't make any difference. What I didn't try was looking a the fields of .BaseType.
Thanks for the reply,
Tom
|
|
|
|
|
Hi!
I need a multicolumn treeview with the ability to put checkboxes in the columns. Do anybody know some article or an open source project?
I found TreeViewAdv on codeproject, which is able to do multiple columns but unfortunately no checkboxes.
P.S. I am programing in C#
thx
|
|
|
|
|
Souds like you need to add checkboxes to te project you found on CP.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I seem to have found a bug in ListView.Items.Insert(int,ListViewItem).
Could someone please try reproduce this? Maybe I could get a bug report submitted.
(Problem seems to occur on 2.0 and 3.5)
Steps to Reproduce:
1. Start a new project
2. Add a ListView with five items in it.
3. Label them 1 to 5 so we can see what happens.
4. Add a Button.
5. Add the following code to Button.Click:
ListViewItem item4 = this.listView1.Items[3];<br />
item4.Remove();<br />
this.listView1.Items.Insert(0, item4);
The items should be arranged like this:
4 - 1 - 2 - 3 - 5
Instead we see this:
1 - 2 - 3 - 5 - 4
Workaround:
I have found if we switch to View.Details before doing the remove/insert then everything works fine.
Replace the code in Button.Click with this:
ListViewItem item4 = this.listView1.Items[3];<br />
View oldView = this.listView1.View;<br />
this.listView1.BeginUpdate();<br />
this.listView1.View = View.Details;<br />
item4.Remove();<br />
this.listView1.Items.Insert(0, item4);<br />
this.listView1.View = oldView;<br />
this.listView1.EndUpdate();
www.wickedorange.com
www.andrewvos.com
|
|
|
|
|
Does the same thing here
"An eye for an eye only ends up making the whole world blind"
|
|
|
|
|
Thanks for checking it out. What version of .NET?
www.wickedorange.com
www.andrewvos.com
|
|
|
|
|
that was using .net 2
"An eye for an eye only ends up making the whole world blind"
|
|
|
|
|
Works, thanks a lot. I am using VS 2010 prof. and had the same problem. Using above code fixed it.
|
|
|
|
|
Hello,
I want to draw two lines which are mitered at the corners (see: http://www.kever.com/images/corners.jpg).
As you can see both lines have different properties (like color) and can even be of different widths. Therefore I draw each line separately (using Graphics.DrawLine and not DrawLines).
My idea is to create a pen with a custom end cap so that the endpoints have a 45 degrees angle.
Anybody knows how to setup a CustomLineCap to achieve this?
Kees
|
|
|
|
|
I am using Crystal Reports for Visual Studio 2005 for making a report including barcodes (Code 39). Whenever the report is generated it does not show the barcode, instead it shows the plain string. I have to export the report to word or pdf to make it show barcodes and then print it. What could be wrong??
|
|
|
|
|
Hi,
I have a long-running application that that periodically outputs the values of many internal fields/variables to a log file.
These variables used to all live in one class, but as the application grew and functionality was added, they became spread out across classes.
The hack-ish solution is to have globally accessible references to the instances of the classes in question, with each class having public properties for the variables. I feel that this is ugly and breaks OO abstraction.
Furthermore, this setup doesn't fix the base problem of seeing when/where things go wrong. Once I see an exception I have to filter through lots of logs to find any evidence of inconsistent state.
What I really want is some kind of global statistics tracking package, where I could do something like the following:
Statistics.AddValue<float>("average.requests.time", 0.0);<br />
Statistics["requests.served"]+= 1.5;<br />
<br />
Predicate<float> p = delegate(float val) { return val > 1; };<br />
Statistics.AddConditionalListener<int>("requests.served", p, <br />
delegate() { Console.WriteLine("why so slow?"); } );</int></float></float>
Basically, a class/package that would store have a name->value mapping, have nice update syntax with operator overloading, and allow you to add listeners for conditions you specify. Oh, and allow you to use a value of any base type, using generics =).
Is there something like this out there? Or, are there classes built into the .NET framework that would let me do this easily (e.g. however conditional breakpoints work?).
|
|
|
|
|
Sounds to me like a use for several of the windows application blocks in the Enterprise library, specifically the logging application block and maybe some custom code built on that.
Also maybe making use of performance counters?
http://msdn2.microsoft.com/en-us/library/aa480453.aspx[^]
|
|
|
|
|
|
This might be a different approach to the problem, but...
What immediately comes to mind is the use of some custom attributes. You might also want to check out the Spring.NET framework. There's a lot you could do with some of the functionality in that framework. This very much sounds like a cross-cutting concern, for which aspect-oriented programming would be well suited.
BW
|
|
|
|
|
Hi,
i have one windows service & i created one setup for windows service using VS.NET 2005. After adding project output getting following error.
"The following files may have dependencies that cannot be determined automatically.
Please confirm that all dependencies have been added to the project.
c:\winnt\system32\shdocvw.dll"
If i build setup getting build error Error
"'shdocvw.dll' should be excluded because its source file 'C:\WINNT\system32\shdocvw.dll' is under Windows System File Protection."
How to resolve please help me.....
Ramana
|
|
|
|
|
Hi everybody!
This is my question (may be a very unprofessional one): when I make a project in Visual Studio and add a reference to some dll file and complete the project( by here every thing is OK!),so the program runs in my system as I want,BUT! as you know if I want to pick the project up and run it in another system so I should add and reference the dlls again. Is there some professional way to add dlls once and the program could be run on every system whitout being worry about adding dlls?
thanks in advance
|
|
|
|
|
Well what dlls are you referencing? If they're part of the .NET framework then they will come with the framework.
www.wickedorange.com
www.andrewvos.com
|
|
|
|
|
I assume you're talking about your own dlls, not framework ones. The professional way is to ship the dlls with the product.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
thank you for your reply
as you mentioned, I am talking about my own dlls (sorry for forgotting to say it. it would be very kind of you if you say what do you exactly mean with "ship the dlls in the product", whould you please explain it a little more.
I thank you again.
|
|
|
|
|
It's pretty straightforward. You choose to write code in a dll, or within the main app. If it's in a dll, then whoever runs the app, needs that dll. So, you have to make sure all your users have the dll. If you don't want it to be a dll, you need to move the code into your exe itself.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi all,
I'm trying to find a way to draw a sort of section of a pie.
Check this image:
http://img186.imageshack.us/img186/9095/piesectionsqv7.png[^]
I'm trying to draw an antialiased line around the blue section.
I have filled that blue section by adding a pie to a path, then adding another pie using the size of the inner circle, which effectively removes the inner ellipse area.
I can't get the same code working for drawing a border line.
The only other way I can think of is using regions and Exclude, but this will break antialiasing. Am I missing something here?
PS. I can't change my draw order, because the image could contain transparent sections.
Thanks in advance
www.wickedorange.com
www.andrewvos.com
|
|
|
|