|
You have to change the current UI culture by assigning a new CultureInfo to Thread.CurrentUICulture and then re-initialize your controls. You should not, however, call InitializeComponents again because that instantiates and re-adds the controls (so you'll get duplicates) to your container. This means that you'll have to break the designer and move all the property assignments out of that method (or better yet, just pull that method apartment into separate calls to instantiate and add, and to assign properties). This is not very common in applications, however. Most applications - especially larger, more complex applications - require a restart.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i just started learning c++ so it may just be a noob question but i am haveing a problem. I am trying to make a prog that writes names and number to notepad. When i run it it write the names and number but on top of it it has a set of numbers (1245068) and that will happen everytime.
Example:
1245068
John
Doe
5678906
Jaine
Doe
23456789
That is what is on notepad. My question is what i am doing wrong to get that set of number and how to just write the first name then last name then number. If anyone could help it would be appreciated. my code is bellow.
#include<stdlib.h>
#include<iostream.h>
#include<fstream.h>
int main(int argc, char* argv[])
{
int x=0, y=0;
string L_Name[100];
string F_Name[100];
int number[100];
char resp;
//Reads if there is already info in there and puts it into array
ifstream read("File.txt");
while(!read.eof())
{
read >>F_Name[x] >>L_Name[x] >>number[x];
x++;
}
read.close();
//Where the user can enter more name
do
{
cout <<"First Name: ";
cin >>F_Name[x];
cout <<"Last Name: ";
cin >>L_Name[x];
cout <<"Number: ";
cin >>number[x];
x++;
cout <<"Would you like to enter another name?(y/n)";
cin >>resp;
}
while((resp=='y')||(resp=='Y'));
y=x;
//writes the origianl names then the new name but here is where i get the
//set of numbers
ofstream write("File.txt");
for(x=0; x<y; x++)
{
write <<F_Name[x] <<endl;
write <<L_Name[x] <<endl;
write <<number[x] <<endl;
}
return 0;
}
|
|
|
|
|
|
Damn, C++ is ugly! All those >> and << make me woozy!
|
|
|
|
|
Anyone know of a reasonably fast grid control for .NET - e.g. something like Stingray for MFC. It just seems that the one thing .NET does badly is good performance on grid controls, or anything thats graphics intensive. Some of them look great, but put more than 50 rows and they crawl when you scroll.
Looking for something that is responsive enought to handle realtime data - not huge amounts of it but to be responsive when it does get it.
From what I can tell the double buffred drawing built into the Windows Forms Control is not as optimised as it could be.
"Je pense, donc je mange." - Rene Descartes 1689 - Just before his mother put his tea on the table.
Shameless Plug - Distributed Database Transactions in .NET using COM+
|
|
|
|
|
http://www.janusys.com/janus/library/
|
|
|
|
|
www.Infragistics.com[^] has an excellent deal.
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
Developer Express[^] has a good one, too. I've used Infragistics and I can tell you from experience that it is good, but their painting mechanism (very extensible) can be very slow on older machines.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Syncfusion www.syncfusion.com[^] has a great grid called "Essential Grid". It is developed by Stefan Hoenig, the man who build before the Stingray grid. It offers a "virtual mode" that can handle millions of rows. I like it!
Regards,
Holger Persch
|
|
|
|
|
Hi,
I'm trying to create a C# web service that takes a string (a file path) and returns the xml document. I'm having some trouble with this task so any help would be much appreciated. If you know of any examples that do this, please share them. My web service function looks like this:
[WebMethod(Description = "Returns the xml file.")]
public XmlDocument GetXmlFile( string sXmlFilePath )
{
if( sXmlFilePath != "" || sXmlFilePath != null )
{
m_XmlDocument.Load( sXmlFilePath );
m_XmlDocument.Save( @"C:\Documents and Settings\dsterling\Desktop\Golfers311.xml" );
}
return m_XmlDocument;
}
m_XmlDocument is a global variable. Below is the code in my web service consumer app.
private void button1_Click(object sender, System.EventArgs e)
{
XmlNode xNode = TWS.GetXmlFile( @"C:\Documents and Settings\bob\Desktop\Golfers.xml" );
xDoc.Load( @"C:\Documents and Settings\bob\Desktop\Golfers.xml" );
xDoc.Save( @"C:\Documents and Settings\bob\Desktop\Doug.xml" );
System.Diagnostics.Process.Start( "notepad.exe", @"C:\Documents and Settings\bob\Desktop\Doug.xml" );
}
Thanks for your help!
|
|
|
|
|
What's the error? And why is your XmlDocument "global"? You realize that more than one person could call this method concurrently, don't you? Your current method will invariably break because someone may get someone else's data since the variable reference could change mid-execution (since a CPU slices time between threads and processes).
Besides, your web application can't access a file on the client machine like that! That just isn't possible. In order to do that, you would have to either specify a path on the server or upload the document to the web server first. This doesn't have to be persistent, however. You could pass a stream that the web service would save to a file. Actually, though, a web server is probably not a good solution for your problem if all you're trying to do is upload a file. Simple HTTP can handle this easier than SOAP. You'd simply make a new HttpWebRequest , get the request stream, and pass the file. The handler on the server would get this stream and save it to a directory, passing back an HttpWebResponse that tells if it was successful or not. Be careful with this kind of solution, however, since the user your web application runs as (by default, this is ASPNET for ASP.NET and IUSR_YOURCOMPUTERNAME for IIS itself) will need write permissions. This means anyone could upload anything and could potentially upload - say - a .aspx file that deletes most of your hard drive! This is where you should try impersonation (even with the web service, which gets a little harder but isn't too bad) using the HttpWebRequest.Credentials property (and disabling anonymous access on the web server with something else enabled like Windows Integrated Authentication), or the WebClientProtocol.Credentials property, which your web service consumer class inherits.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I want to have a dynamic array that I can have as a lookup table so some elements will contain data and some will contain nothing.
Here's what I have now (This doesn't work yet)
<br />
ArrayList employeeLookup = new ArrayList();<br />
<br />
if (employeeLookup.Capacity < (employeeID + 1))<br />
{<br />
employeeLookup.Capacity = (employeeID + 1);<br />
}<br />
<br />
employeeLookup[employeeID] = i;<br />
This causes an index out of range error, because Capacity doesn't initialize anything. I can't just use the .Add method cause I need the data to be in a specific element of the array. Not to "troll" this message but is there a cleaner more C++ way of doing this? Hard to figure out without using pointers or allocating memory manually. Just looking for a clean way to accomplish this.
Thanks!
|
|
|
|
|
I'm wondering why you must have an array with unknown length fixed to an indeterminate length.
Wouldn't this be better served by using a Hashtable ? Then you don't need to worry about lengths. If employeeLookup is a Hashtable then employeeLookup[someemployeeid] is the value you are working with. No messing with lengths at all.
|
|
|
|
|
Instead of using an array by itself you probably need to deploy a more complex collection. For example:
public class EmployeeCollection:System.Collections.SortedList
{
}
This would provide you with a base collection that associates a key:value pair. Your key would be your employeeID and your value would be your employeeObject.
You would have to implement your Add, indexed access, and Remove to have them strongly-typed for your employee object and your employee ID along with validation that a valid ID is passed for adding to the hashtotal.
This particular collection would then allow you to access either by index or key.
myObject = employeeLookup[employeeKey];
myotherObject = employeeLookup[245];
_____________________________________________
Of all the senses I could possibly lose, It is most often the one called 'common' that gets lost.
|
|
|
|
|
I could go through find the highest employeeID and then create a fixed array, then I wouln't have to worry about any resizing whatsoever.
Basiclly I want to get to the point where eventually I am going to do assignments to another array by using NewArray[employeeLookup[employeeID]] = 5;
I haven't used the hastable object before but it seems like a lot of overhead for something simple, espically when I never plan to use any of the search functions or anything like that it offers (Could be wrong on this).
|
|
|
|
|
The SortedList is one way of deploying an array that also gives you a keyed access (which is what you are really asking for). HashTable is the only way you can create a keyed lookup within an array or collection. It is also the only way to avoid getting an index exception if you go to get a number that does not exist in the array. You really are not implementing any significant overhead when you do this. In fact I think you are adding more overhead by trying to set a capacity for an array.
_____________________________________________
Of all the senses I could possibly lose, It is most often the one called 'common' that gets lost.
|
|
|
|
|
I am getting the following exception when I try to run the following MSDN Article[^].
An unhandled exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll
Additional information: Because of security restrictions, the type System.Runtime.Remoting.ObjRef cannot be accessed.
I have not changed any of the code in the example, just loaded it in Visual Studio and did a build. Any ideas what is wrong?
|
|
|
|
|
Without knowing what object the exception is in reference too, you usually see this exception when an object is specifically made to not be marshalled for remoting. There are good security reasons why you don't want some objects to serialize let alone tell another computer the data structure.
Can you tell us any more? There is code access security that needs to be addressed for remoting but if you are running the client and the server on the same machine you should have all of the access you need to make it work.
|
|
|
|
|
<br />
internal static int ProcessRun(string[] args, Type userApplicationType) <br />
{<br />
SingletonCommunicator comm = (SingletonCommunicator)RemotingServices.Connect(typeof(SingletonCommunicator), SingletonCommunicatorUrl);<br />
<br />
if (comm.Control == null) <br />
{<br />
comm.Control = new SingletonCommunicatorControl();<br />
IntPtr h = comm.Control.Handle;<br />
<br />
UserApplicationContext context = (UserApplicationContext)Activator.CreateInstance(userApplicationType, true);<br />
comm.Control.App = context;<br />
<br />
comm.Control.App.FirstInstanceRun(args);<br />
}<br />
else <br />
{<br />
comm.Control.App.SecondInstanceRun(args);<br />
}<br />
return 0;<br />
}<br />
<br />
This is the method it kicks back to on the line: IntPtr h = comm.Control.Handle;
With this exception:
An unhandled exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll
Additional information: Because of security restrictions, the type System.Runtime.Remoting.ObjRef cannot be accessed.
Full source code can be found at MSDN link[^]
|
|
|
|
|
If you are running the 1.1. Framework and using VS 2003, then you need to add a command to your remoting initialization.
BinaryServerFormatterSinkProvider serverProv =
new BinaryServerFormatterSinkProvider();
provider.TypeFilterLevel =
System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
BinaryClientFormatterSinkProvider clientProv =
new BinaryClientFormatterSinkProvider();
IDictionary props = new Hashtable();
props["port"] = 1234;
HttpChannel chan = new HttpChannel(props, clientProv, provider);
ChannelServices.RegisterChannel( chan );
The 1.1 framework raised security of remoting. Default is set to the TypeFilterLevel.Low which does not allow marshalling ObjRef. Adding the TypeFilterLevel and setting it to Full will get around the issue.
_____________________________________________
Of all the senses I could possibly lose, It is most often the one called 'common' that gets lost.
|
|
|
|
|
Where do I change the security for remoting?
|
|
|
|
|
AFAIK there's no global place to change this.
You have to configure your channel formatters to use full type filtering either programmatically or by using your app.config file.
The ugly thing is that .NET 1.0 doesn't understand the "typeFilterLevel" property, so you have to decide whether you app will run with .NET 1.0 or 1.1.
Take a look here for details.
Oh, and because you use the framework from the "Real World Applications Sample" articles on MSDN: In case you haven't done yet don't forget to override InitializeLifetimeService() in the SingletonCommunicator class or you won't be able to activate your running app after about 2 mins of inactivity...
|
|
|
|
|
I have not looked at the MSDN 'real world sample' so I cannot speak specifically to that one project. mav.northwind is correct, though, in that there is no single way you implement TypeFilter ing...it all depends on how you establish your channels.
The example might not address the fact that you can configure your channel either in the configuration file or in code. The code I posted in my reply gives you the development direction within your program.
Generally: If you have an application - and it always connects to only one machine - and you never have to dynamically change this -- then you can use a configuration section. The GotDotNet article that mav pointed to will give you a discussion on the config file pieces.
Specifically: In any remoting application that we have put together we do not have a single machine being connected to. Thus we allow the user to answer a few questions in a wizard and then we let them dynamically choose the server to connect to. Then, programmatically, we get the URL from the user choice, append the remoting object URI pieces, and then create and establish the channel to the specific server. We have control over the formatters as well as defining the needed parameters such as killing the proxy server search. It minimizes what is exposed to the client that they can go mucking about in, it lets us update servers by modifying a simple config statement, and it does no expose any remoting-specific information outside of what is needed at the IIS side.
_____________________________________________
Of all the senses I could possibly lose, It is most often the one called 'common' that gets lost.
|
|
|
|
|
Hi,
I have a TabControl with 4 TabPages. Based on Access Permissions I want to grey out the selection of a particular TabPage.
I used following property to disbale:-
tabControlDeal.TabPages[3].Enabled = false
But this disables all the controls on TabPages[3], but doesn't greyout TabPage selection.
Is there any way out to greyout TabPage selection.
Thanks in advance
Ruchi
|
|
|
|
|
You could owner-draw the tabs and set the text color to SystemColors.GrayText based on the TabPage.Enabled property. Then, just make sure to reset the focus in case someone clicks on the tab. It's simplistic, but there's not a whole lot you can do with the TabControl provided in the .NET FCL (mostly because there's not a lot you can do with the tab common control it encapsulates).
Microsoft MVP, Visual C#
My Articles
|
|
|
|