|
This is more of an implementation issue than a OO issue.
To get your implementation to use OO better you should use typed collections. At present C# does not support Generics (but it will in V2.0) so you will have to manually create a typed collection. You can google for some automated tools that will build typed collections.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
Thanks for the pointer, man! Typed collections seems to be what I needed.
|
|
|
|
|
You can also extend CollectionBase and override the methods and property that would normally return object . This is possible because those methods - required because the interface is implemented - are implemented with explicit interface declarations. As Colin said, there's tools available to help you, but you should at least understand what is going on with the source they generate.
If you don't extend CollectionBase or another base class, you have to implement all the interfaces required for your code yourself.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
dear all,
I have some buttons in a toolbar.
on all these buttons, there are some icons.
I want to change the icons on the buttons of my toolbar to another when the mouse is over it, so i use the toolbar_mousehover event to detect it...
However, I don't know how to get the toolbar button value that the mouse is currently hovering it from the arguments.....any ideas?
thanx a lot!
|
|
|
|
|
You could try to cast the sender as a ToolBarButton .
private void Toolbar_Hover(object sender, EventArgs e)
{
ToolBarButton b = sender as ToolBarButton;
if(b != null)
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
This would only give you the ToolBar , actually, since it's the Control raising the event. You have to perform a hit test (which I briefly showed below). Basically, the ToolBar in the .NET BCL sucks. Thank goodness for WinBars in .NET 2.0!
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
That's what I get for not having .NET installed here at work. I just ordered a copy of Visual Studio .NET 2003 last Friday for my next project (conversion from Java to .NET). Thanks for clairfying.
- Nick Parker My Blog | My Articles
|
|
|
|
|
You need to perform a hit test. For some reason, Microsoft didn't define this on the ToolBar class. You do this by getting the MousePosition , transforming those screen coordinates to the ToolBar 's client coordinates, then P/Invoke native APIs:
public class MyToolBar : ToolBar
{
public ToolBarButton HitTest(Point p)
{
IntPtr retval = SendMessage(Handle, TB_HITTEST, IntPtr.Zero, p);
int index = retval.ToInt32();
if (index >= 0)
{
foreach (ToolBarButton button in Buttons)
if (button.Style != ToolBarButtonStyle.Separator)
if (index-- == 0) return button;
}
return null;
}
[DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, uint msg,
IntPtr wParam, ref Point p);
private const int TB_HITTEST = 0x0445;
} To use it:
myToolBar1.MouseHover += new EventHandler(myToolBar1_MouseHover);
private void myToolBar1_MouseHover(object sender, EventArgs e)
{
Point p = Control.MousePosition;
p = myToolBar1.PointToClient(p);
ToolBarButton button = myToolBar1.HitTest(p);
if (button != null) MessageBox.Show("You're over the " + button.Text +
" button.");
} This is untested, but should give you some idea of what to do.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi everyone
Does anyone know of a decent (and free! ) C# refactoring plugin for VS.net?
I had a look at "Resharper". The refactoring capabilites were good, but I didn't go for the auto complete drop downs much. Also it seemed to slow down VS.net a lot, and the uninstall left me unable to add a new class or project. (There was a note on their site about this, but it left me having to do a complete VS repair)
I had a look around on google, but didn't see anything.
Has anyone else tried ReSharper? Any thoughts?
Best Wishes
Steven
let the stormy clouds chase everyone from the place
|
|
|
|
|
which refactoring methods do you need?
VS2005 will have quite a few (but not as many and not as nice as Eclipse for Java).
You'll be able to download Beta in few days.
|
|
|
|
|
ahh yes well - the ones that eclipse has for java is exactly what I was thinking of
|
|
|
|
|
The one that I wanted the most from eclipse was to generate getters/setters.
That's why I wrote my own VS add-on for that:
http://www.adersoftware.com/index.cfm?page=vsPropertyGenerator
|
|
|
|
|
cool thanks - i'll look into it
|
|
|
|
|
My problem is this. I want to download a file from the webbserver and save it to a local client. And i the work flow is like this. After the user has register his customer data, he reicive an email with a link to the file on the server and then the dowload starts. I don´t have any idea of how to do this
Could anyone give me some idea´s or example of how to do this or some other way to do this
Sorry for my poor english
|
|
|
|
|
Just create the link to the file, the browser will handle the open/save dialog.
Example: http://yourserver.com/files/update.zip
|
|
|
|
|
Hi, I want to create a button control that scales the image well.
If I use an ordinary Button it won't scale the image at all.
Of course I can create images of correct size, but I want to be able to
allow users to run it with large fonts set and still get the same look.
So What i've done now is override the button and override the onpaint
to draw either a selected "button pressed" image or a "button not pressed"
image. But It would be cleaner to use only a single image and paint the
pressed effect with the ControlPaint.DrawButton(..) function.
So my question is:
does anyone know how wide the button borders are?
Is this dependent on the current font settings also,
or is it always for example 2 pixels?
|
|
|
|
|
i think its usually 2, but what about the themed look?
|
|
|
|
|
i'm a beginner on 3D programming and currently using DirectX 9.0. I have trouble when coding and hope to get help from you guys.
Here are the application requirements:
-application to show warehouse rack in 3D
-user able to view the rack in different angle
-user able to select the item in the rack
-when item selected, the information of the item need to show to user
I does not know how to use mouse to select and show the item info. I hope to get some advices and tutorials or articles on the regarding requirements above.
thanks
|
|
|
|
|
Wow...you've got your work cut out for you. What I would do if I were you:
1. Google like a madman for "Direct3D 9.0 tutorials"
2. Download the DirectX SDK documentation
3. Look heavily into the following areas:
- Microsoft.DirectX.Direct3D.VertexBuffer
- Microsoft.DirectX.Direct3D.Device
- Microsoft.DirectX.Direct3D.Texture
- Microsoft.DirectX.Direct3D.Transforms
- Vector3.Unproject and Vector3.Project
The VertexBuffers hold the "points" that make up the 3D models in your application. The Device is a object that represents the drawing space of your app. Textures are painted onto the 3D models to make them look better, and Transforms are how you move objects around in your "world", as well as your viewing location, or camera. The Project and Unproject methods take a 2D point and convert it into 3D viewspace, and vice-versa.
To summarize, start reading a LOT. You'll be working with a heavy amount of trigonometry, geometry and matrix algebra.
Jeremy Kimball
I have traveled the gutters, lo these many days, with no signs of life. Well met.
-brianwelsch
|
|
|
|
|
|
If you needed another reccomendation on this, here it is. The book is awesome!
|
|
|
|
|
hi,
I am using two RichTextbox controls in my form.
After pressing a button in the form, i want the rtf data of one control to be appended to the other RichTextbox.
rtbox2.rtf = rtbox2.rtf + rtbox1.rtf ; ( is not working )
by giving,
rtbox2.rtf = rtbox2.rtf.substring(0,rtbox2.rtf.length-10) + rtbox1.rtf ;
it is working for the some time. But after changing the colors of rtbox1 data, it is not working ( appending but colors are different from the actual rtbox1 data ).
can any one solve my problem?
M.V.Ravikumar.
|
|
|
|
|
I got the solution.
rtbox2.SelectionStart = rtbox2.rtf.length; ( or rtbox2.text.length )
rtbox2.SelectedRtf = rtbox1.Rtf;
But now, i got another problem.
In the rtbox2 (a rich text box) as the strings are added to it.
The vertical scroll bar is moving up ( means always firstline is shown ).
Can i see the latest contents in the rtbox2, as and when the content is added to it, without manually moving the scrollbar.
I tried with rtbox2.scrolltocaret() ( even after selecting the last character ) . But it is not working.
Can any one solve the problem
M.V.Ravikumar.
|
|
|
|
|
First, you have to put the caret at the end of the text. Then you have to make sure that the RichTextBox has the focus, otherwise, ScrollToCaret will not work.
rtb2.SelectionLength = 0
rtb2.SelectionStart = rtb2.Text.Length()
rtb2.Focus()
rtb2.ScrollToCaret()
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
how to get sqlserver names in local net,thank you
|
|
|
|