|
In the System.Text namespace, there are a bunch of classes ending with Encoding. They have a method called GetBytes with a bunch of overloads. So in the case of Unicode text, you would use:
byte[] string2byte = System.Text.UnicodeEncoding.GetBytes("This is a string");
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
Microsoft has reinvented the wheel, this time they made it round.
-Peterchen on VS.NET
|
|
|
|
|
Why do you need it as a byte[]?
|
|
|
|
|
I didn't in the end. I am using a StringBuilder to build a report from a DataSet, which I then want the browser to save to the users HDD. The code I was basing it on streamed all sorts of things and so used Response.BinaryWrite. I only need Response.Write, as it is always a string ( obviously ). It all works now, with the exception that it insists on ignoring the directive to set the filename, instead saving my test with the name of my aspx.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Great! So my hard work was for nothing?
[edit]Actually, I have noticed that Response.Write doesn't pay attention to the filename, which is a real shame, cause then the user isn't able to open it automatically. I have seen it several times, but still have no idea how to fix it. /edit]
Hey, what can I say? I'm a chick magnet...a babe conductor...a logarithm for the ladies.
-Strong Bad from HomeStarRunner.com
Essential Tips for Web Developers
|
|
|
|
|
David Stone wrote:
Great! So my hard work was for nothing?
No, I was really pleased to know the answer, and filed it away for future reference.
Current thought has it that my IIS is stuffed, because the same code works on other peoples machines.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
|
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
|
|
|
|