|
|
I create a new control inherited from TextBox, all the TextBox's property are inherited. but I don't want some property, e.g. BorderStyle, BackColor... How do I do it?
linjie
|
|
|
|
|
I don't think it's possible to get rid of these properties but you can do a fairly effective job of hiding them with
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] .
Paul
Pleasently caving in, I come undone - Queens of the Stone Age, No One Knows
|
|
|
|
|
I need some reassurance that I'm not blind...
Is there no "Dictionary" class in the System.Collections namespace, but rather only the DictionaryBase class that requires you to code your own derrived class?
Mike Stanbrook
mstanbrook@yahoo.com
|
|
|
|
|
You can use a hashtable like a you would an arraylist, or one of these:
HybridDictionary Implements IDictionary by using a ListDictionary while the collection is small, and then switching to a Hashtable when the collection gets large.
ListDictionary Implements IDictionary using a singly linked list. Recommended for collections that typically contain 10 items or less.
PropertyCollection Contains the properties of a DirectoryEntry.
PropertyDescriptorCollection Represents a collection of PropertyDescriptor objects.
SortedList Represents a collection of key-and-value pairs that are sorted by the keys and are accessible by key and by index.
Eish I must get sleep You would swear South Afican time was GMT - 6
WebBoxes - Yet another collapsable control, but it relies on a "graphics server" for dynamic pretty rounded corners, cool arrows and unlimited font support.
|
|
|
|
|
look in System.Collections.Specialized
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Developing a network file backup application and need to
be able to see all machines on a network, select
drives/dirs/files for backup.... currently, I have an app
similar to Windows Explorer, with a treeview to look at
my own computer's data, with no problems... need to
add "My Network Places" to this (similar to Windows Explorer)
and be able to go out on
the network and get similar info for other
workstations.. plus I need to be able to create folders
and copy files to these PCs... I think I'm kinda close
with System.DirectoryServices and System.Management, but
can't seem to find what I'm looking for... any help or
suggestions would be much appreciated... thank you.
|
|
|
|
|
Has anybody written a reflection routine that can clone a control? For Copy & Paste of a control...
And before anybody mentions it again, Yes I am programming in VB.Net, but you guys know more system level stuff. Answers accepted in c#
|
|
|
|
|
|
Blarggh!
I'm subclassing controls as they are added to a control. All works well apart from when I resize them. They flicker like crazy and redraw (this resize is done following the mouse, so there are many resizes, i.e. adjusting the width to follow the mouse) incorrectly.
If I place controls on before the app runs these controls don't flicker (i.e. they are not subclassed).
The textbox controls draw a border inside themselves (the backcolor shows through where the border is inside the control)
Does anyone have any idea what I'm missing. I'm guessing it's got something to do with WM_PAINT?
See problem
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) Handles _SubClassArray.CallBackProc
'This procedure handles messages from the child controls
Select Case m.Msg
Case WM_LBUTTONDOWN
'select object
_ControlAtMouseDown = Control.FromHandle(m.HWnd)
_MouseDownTick = _TickCount
_MouseUpTick = -1
_MouseState = MouseState.LeftDown
_MouseDownTime = -1
m = Nothing
Case WM_LBUTTONUP
'stop current operation
_MouseState = MouseState.LeftUp
_MouseUpTick = _TickCount
_MouseDownTime = _MouseUpTick - _MouseDownTick
Me.Cursor = Cursors.Default
ChangeOperation(Operations.None)
Case WM_RBUTTONDOWN
'Show menu
_MouseState = MouseState.RightDown
Case WM_MOUSEFIRST ' Mouse over
m = Nothing
Case WM_SETFOCUS, WM_LBUTTONDBLCLK, WM_MOUSEHOVER, WM_MOUSEMOVE, WM_MOUSELEAVE, WM_KEYDOWN, WM_KEYUP
'Dump these messages to stop the control reacting
m = Nothing
'Case WM_PAINT
' 'redraw control
' _ControlToPaint = Control.FromHandle(m.HWnd)
' _ControlToPaint.Refresh()
End Select
MyBase.WndProc(m)
End Sub
|
|
|
|
|
From the MagicLibrary's readme (tips section):
You have just spent several days writing a beautiful looking custom control but are faced with one last problem that is spoiling the whole effect. Whenever the control is redrawn it flickers. This is most obvious when the control is being resized and so redrawn many times in succession.
Solving this problem is very easy with the .NET Framework. If you come from a C++ and GDI background then the solution was to create a memory based bitmap, draw the control onto the bitmap and then blit this to the screen (otherwise known as double buffering). This is such a common requirement that the UserControl class actually implements this functionality for you. All you need to do is include the following two lines of code into your class constructor.
SetStyle(ControlStyles.DoubleBuffer, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
The first line will request that double buffering be used whenever the OnBackground or OnPaint methods are called. This will reduce the amount of flicker but may not remove it completely as painting the whole control still results in two separate blitting operations.
The second line of code above is used to ensure that only a single blitting operation occurs when drawing. This occurs when the underlying windows WM_PAINT message is processed. When this happens it will create the memory bitmap, call the OnBackground method, call the OnPaint method and then finally blit the result to the screen.
The only drawback to this technique is the greater use of resources. However, most controls are relatively small in screen size and so this is unlikely to be an issue.
WebBoxes - Yet another collapsable control, but it relies on a "graphics server" for dynamic pretty rounded corners, cool arrows and unlimited font support.
|
|
|
|
|
Is there anybody out there that hasn't looked at the Magic Code? I am already using this technique and the effect happens whether this is on or off.
I think the subclassed controls are not getting a message. I have recently realised that the ComboBox (DropDownList) has a similar problem. The actual control is subclassed and does not receive the messages, but the text control inside it still recieving messages! i.e. THe combobox does not react to a mouse click but the text control inside it does!
This is getting wierd....
HEEEELLLLLPPPPPPP!!!!!!
|
|
|
|
|
Why are you setting m to Nothing when you handle most of the events?
Because it is passed ByRef you are changing the value of m in the caller as well as in the base implementation of WndProc. To my knowledge this isn't the behavior you want, instead you should just not call MyBase.WndProc if you don't want the default behavior.
No idea if it has any effect on your problem, but it just struck me as odd.
James
"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation
|
|
|
|
|
Sorry James,
I'm from a VB background and its a habit. It doesn't affect the routine, I tried it
|
|
|
|
|
It gets worse...PLEASE HELP MEEEEeeeeeee........
Does anyone know how to stop a ComboBox (Drop Down List) getting focus? If I stop CBN_SETFOCUS the control still sends focus to the text editing part of the combo and the caret appears.
What I'm trying to do is stop all controls reacting to usr input. I cant just set them to .Enabled = false because most of them turn gray and don't look like normal controls.
Any ideas?
|
|
|
|
|
|
Look at the Invoke method.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
|
I have a problem it is described as under
I want to load an ascx control in the class (no the web form code behind file) file so that i would be able to render the control.
what i am doing is as follow
Page page = new Page ();
creating the page instance and then loading the control
Control cont = a.LoadControl(path );
but it throws a null pointer exception
Remember i am in the class file where "Page" reference is not available that is y i have to make the instance of a page
Please help me
waiting for ur sids
|
|
|
|
|
Gurus Guru wrote:
Remember i am in the class file where "Page" reference is not available that is y i have to make the instance of a page
In that case making a new Page isn't going to help you, because it will be a reference to a brand new page, not the one you are currently processing.
To my knowledge you'll have to construct your class so you can pass in the Page object it should be using. But I don't know much about ASP.NET so you may be better off posting in that forum.
James
"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation
|
|
|
|
|
But the problem is that my code is written in a thread and it never have any interaction with any web page
The scenario is that i have written a thread class that mails some search results after some time i have a user control that takes some results array (my own defined class) and display it in the data grid so i thought to use this control
Now i am in the class file and want to load the control so that i may be able to render that control afterwords and then email the html to the user
getting me
But still no use
|
|
|
|
|
Did u try something with
System.Web.HttpContext.Current. ...
(I am not so sure about that... But this has some bunch of properties that might help you.)
deepak
Deepak Kumar Vasudevan
http://deepak.portland.co.uk/
|
|
|
|
|
The problem i am running it the application in thread and using a singlton and factory pattern too and it is a demon thread and dont have to do any thing with any web form i have at the end passed the page reference who calls the thread but when in the class file after the thread has been created and i try to bind the results with the datagrid it raise the exception that request is null
|
|
|
|
|
Hi.
I want to create a C# program that will be able to write in a text file every application that the user/machine ran. This file will resides in a specified directory on a particular machine. I have read that this is possible using WMI in a client-server environment. I am running Active Directory using Windows .Net Server RC1. I don't have any experience with WMI yet. Is WMI supported in C#? What is the namespace where I can find the classes specific to WMI? I would greatly appreciate it if someone can show to the basic program structure for this or links relevant to this matter. Thanks
|
|
|
|
|
swarm wrote:
Is WMI supported in C#?
Yes.
swarm wrote:
What is the namespace where I can find the classes specific to WMI?
System.Management
You can find very good articles about WMI in C# in this site.Search this site with WMI or System.Management Keyword.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|