|
using System.IO;
using System.Xml;
MemoryStream ms = new MemoryStream();
XmlTextWriter tw = new XmlTextWriter(ms,new System.Text.UTF8Encoding());
tw.WriteStartDocument();
tw.WriteStartElement("...");
tw.WriteEndElement();
tw.WriteEndDocument();
tw.Flush();
tw.Close();
String s = System.Text.Encoding.UTF8.GetString( ms.GetBuffer() );
MessageBox.Show( s );
|
|
|
|
|
Thanks a lot. It works..... somebody, send me an others solution which work too
public class StringWriterWithEncoding : StringWriter
{
Encoding encoding;
public StringWriterWithEncoding (Encoding encoding)
{
this.encoding = encoding;
}
public override Encoding Encoding
{
get { return encoding; }
}
}
Then you'd do:
XmlTextWriter = new XmlTextWriter
(new StringWriterWithEncoding (Encoding.UTF8));
-=zoltx=-
|
|
|
|
|
I have to admit the StringWriter derived class is a much better approach to the encoding issue. Use it instead of the C-like memory streams I have suggested.
|
|
|
|
|
You are great ........ Thanks a lot ......
-=zoltx=-
|
|
|
|
|
Hello,
Is there a way a class can access private and protected members of another class? Like friend keyword in C++. I haven't discovered it.
Thanks!
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
Alexandru,
a similar construct to friend is the internal keyword, which allows access from within the same assembly, but not from outside.
Wolfgang
|
|
|
|
|
Thanks for the reply.
However the protected members I wanted to access were some WebControls that the designer created for me in a ASP.NET page. I didn't want to manually change the access level for those object so I decided to redesign my application.
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
I am creating a custom control which inherits from combobox class.
Now, I want to prevent some events from being occured at special times, for example I want my combobox, when is in droped down state, not responsing to click events, to prevent it from getting back to its default state. I think it may be done throughout overriding OnClick eventhandler or some better one to handle.
Please help me!
Regards
|
|
|
|
|
Meisi wrote:
I think it may be done throughout overriding onclick
Correct, more specifically override OnClick and in the cases where you don't want the Click event to fire just don't call base.OnClick() . Then when you want the Click event to fire ensure you call base.OnClick() .
James
"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation
|
|
|
|
|
Have you any suggestion exactly about this :
"I want my combobox, when is in droped down state, not responsing to events, to prevent it from getting back to its default state"
The OnClick is not proper for this situation.
Regards
|
|
|
|
|
Is there way to make int i = (int)3.6; give a rounded as opposed to floored result? Some global setting?
|
|
|
|
|
|
Don't know about anyone else, but I can't see it listed as a namspace from the VisualStudio .NET IDE!!!!!
Help!!!!
Where is it. Can't see it at work on my NT4 box or at home on my Win2K box.
Its not there!!!!
Anyone know why?
Quote from a clever bloke :
"I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones." - Albert Einstein
|
|
|
|
|
Right click on the 'References' tree node in the project view. Goto 'Add Reference', then look down the .NET list for System.EnterpriseServices, click select then OK.
You can now use the namespace in your code. Howzzat!
"De most compwehensive image seawch on de web." - Google in Elmer Fudd Language "But a fresh install - it's like having clean sheets" - Chris Maunder Lounge 3 Mar '03
Jonathan 'nonny' Newman Web Designer, Programmer, Lover, Visionary Leader...
Homepage [www.nonny.com] [^]
|
|
|
|
|
Okay. I'm slow of the mark today.
Thanks,
Giles
Quote from a clever bloke :
"I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones." - Albert Einstein
|
|
|
|
|
(Precursor)
http://www.codeproject.com/cs/menu/dockingcontrol.asp?target=dockstyle%7Csize
discusses adding controls to a form using AddRange in a specific order.
(The problem)
I am trying to do the following, dynamically in a form constructor:
1. Add TabControl to form. TabControl is set to DockStyle=Fill
2. Add TabPage to TabControl. (Automatically fills TabControl)
3. Add Panel to TabControl.
Problem: I need to access the size of the TabPage AFTER the DockStyle=Fill has come into effect. This is to precisely position the panel in a location on the TabPage.
But during initialization, the only Width/Size I can get from TabPage, is the DefaultSize (100 x 200)
Is there any command I can call to force the TabControl to fill the parent form, then retrieve the new size/width of the contained TabPage after the fill?
Thanks for suggestions.
|
|
|
|
|
Use Load or Resize event of controls (panel etc)
Hi,
AW
|
|
|
|
|
Hi
Thanks for reply. However it still seems no clearer. I also found a Layout event.
The question is: At what time, during the instantiation of a control, can we be certain that the DockStyle Fill has been applied to the controls width/height. And therefore, at that point, we can be certain to rely on those as containing the final values, and not the DefaultSize values?
MSDN seems unclear on this in any of the event descriptions.
Cheers
|
|
|
|
|
I have a Treeview/Listview pair in a Windows Form that behaves like Windows Explorer, displaying folders and files on my machine... both controls have checkboxes for each entry so I can keep track of what's been selected.
Aside from maintaining a current global TreeViewEventArgs object, is there a good way to update the Treeview when you click the listview and receive the listview_AfterCheck event? I want to be able to have the parent (folder) node in the treeview become "checked" when I "check" a file in the list view... wondering if the .NET framwork provides some sort of communication mechanism for this..???
thanks.
|
|
|
|
|
Since a form hosts both the treeview and the listview, I would override both OnBeforeCheck event handlers, and provide a default implementation to them, calling a unique method at the form level. This method in turn Invokes Check() methods exposed by tree nodes, and list nodes.
Nothing really new to talk about, that's much like delegating the application logic to a control manager.
|
|
|
|
|
Interesting, I guess I've never overridden a windows-fired event... how do you get windows to fire the overridden vs. the non-overridden event?
thanks.
|
|
|
|
|
Silly question probably, but...Whats the easiest way to communicate from a child Window to a parent window. For example, when the app starts, I want a login form to popup. When entered, that data needs to be available throughout the app. Currently I am using the "OnMdiChildActivate" event on the parent window which works, but it seems as if there should be a better way.
Cody C
|
|
|
|
|
You could do this in a couple of ways.
If you are in full control of the form that is poping up, you can get the required information by capturing the OnClosing event of the logon form, add the event handler in your MDI parent's load event when you open the mdi child:
LogonForm f = new LogonForm();
f.MdiParent = this;
f.OnClosing += new EventHandler(this.Form1_Closing);
Having done this, write code along these lines to capture properties from the closing logon form:
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
LogonForm f = (LogonForm)sender;
string Uname = f.Username;
string Pword = f.Password;
}
obviously you'll need to set up properties such as Username & Password in you logon form that are public.
An other way may be to pass up a custom Logon class from the Parent to the child by reference, you can then populate it from the logon form and the information will be available to the parent.
Let me know if you'd like me to elaborate on either of these methods.
|
|
|
|
|
Thanks..thats an interesting idea. I actually did it a different way by when the user logs on successfully, having the child window (logon form) populate some public properties of the parent window. I like the idea of having the parent window handle events of the login window however.
|
|
|
|
|
I have written a simple web service, well it's kind of complexe, but it is working GREAT on my local machine. I can call it via the URL and it does EXACTLY what I want it to do (http://localhost/webServiceName/WebService.asmx/theWebMethod?var1=stingVar1&var2=stringVar2....). So now I want to put it out on my production server. So I follow all the steps that are laid out in this example.
When I run it, I get this error:
==========================================
Server Error in '/agnWmEventTools' Application.
--------------------------------------------------------------------------------
Request format is unrecognized.
Description: An unhandled exception occurred during the execution of the current web request.
Please review the stack trace for more information about the error and where it originated
in the code.
Exception Details: System.InvalidOperationException: Request format is unrecognized.
Source Error:
An unhandled exception was generated during the execution of the current web request.
Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: Request format is unrecognized.]
System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response) +388
System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath) +94
System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, String path, String pathTranslated, Boolean useAppConfig) +718
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() +95
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +173
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.510; ASP.NET Version:1.1.4322.510
==========================================
I know this has to be something simple, right?? The only difference is in the systems running it. When I first put this on, I got an MDAC issue so I upgraded the MDAC on the server running .Net and that error went away and now I get this error above.
Thanks,
Bill K.
|
|
|
|