|
Why not use CultureInfo.CurrentUICulture ?
|
|
|
|
|
That is the property returning current thread culture settings that is UI thread.
Чесноков
|
|
|
|
|
A new thread receives culture/UI culture from the Windows system - in my opinion that's a bug (but Microsoft may see that differently). I use to set the UI culture with a value from the .exe.config file - that can also be applied in a newly started thread. Otherwise, have a (static) member in some class/object you can access from the background worker.
|
|
|
|
|
Bernhard Hiller wrote: I use to set the UI culture with a value from the .exe.config file - that can also be applied in a newly started thread
I do that in UI application, but background worker is in class library which is used by UI application.
Class library is not supplied with config file by intent.
I know it is possible to pass an argument to a thread or access its class variable or static field set up externally but I wonder if it was possible to getbackground thread handle and change its culture.
Чесноков
|
|
|
|
|
Hello Everybody,
If my application is running in administrator Previledge (Run as admin) then i am executing any application from this
application.The Executed application is also run with Administrator Mode. But i want to run it with current user Previledge.
pls describe me how can it possible.
Thanks
If you can think then I Can.
|
|
|
|
|
eg_Anubhava wrote: But i want to run it with current user Previledge.
Only the user can run processes under his privileges, if you're an admin you'll spawn processes with admin-privileges. You can use the Proces class to spawn a process under a different account, but you'll need the users' name and password. Point is that your process isn't in the users' space, and it has to provide the right credentials before it's allowed there
I are Troll
|
|
|
|
|
I have decided that I need a better way of validating data.
I currently have various objects that can validate information, for example:
if(TextBoxValidator.IsValidTextBox(tbText))...
Also I tend to use the Debug.Assert() methods often, making sure that null or invalid states of variables are shown.
Its starting to get repetitive when I validate:
if(fileDetails.ToString() == string.Empty || map == null) return Common.ReturnResult.Failed;
if(map.StaticImages == null || map.Tiles == null) return Common.ReturnResult.Failed;
if(map.Infomation.Columns == 0 || map.Infomation.RootContentFolder == string.Empty || map.Infomation.Rows == 0 || map.Infomation.TileSize == 0)
return Common.ReturnResult.Failed;
There must be a better way to validate methods input and such than this!
Any suggestions, Thanks
|
|
|
|
|
One way is to avoid nulls in the first place, but if you need to check , here is a start, it is longer but clearer to read:
...
bool Success(footype map)
{
if(map.StaticImages == null)
return false;
if(map.Tiles == null)
return false;
if(map.Information.RootContentFolder == "")
return false;
if(map.Infomation.Rows == 0)
return false;
if(map.Infomation.TileSize == 0)
return false;
}
public Foo()
{
if(fileDetails.ToString() == string.Empty)
return Common.ReturnResult.Failed;
if(map == null)
return Common.ReturnResult.Failed;
if(!Success(map))
return Common.ReturnResult.Failed;
return Common.ReturnResult.OKorWhatever;
}
Can you change the map object? If so the Success Status is probably better off there as a property, you could also break this down into further sub-properties such as HasImages , HasInformation etc
|
|
|
|
|
May be better to use CASE statement.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC League Table Link
CCC Link[ ^]
|
|
|
|
|
What about an "IValidable " interface defining a method "Validate() "?
When "map" and its properties implement it, you could simply call map.Validate() which would encapsulate that logic there.
|
|
|
|
|
Thanks for the reply,the problem is that I would have allot of validation objects everywhere, which wouldn't be very fun to use...
|
|
|
|
|
HOw about
public bool CheckForNulls(object[] thingsThatShouldntBeNull)
{
return thingsThatShouldntBeNull.TrueForAll(x => x != null);
}
CheckForNulls(new object[]{dumbshitCoderField1,dumbShitCoderField2);
|
|
|
|
|
Anyone know why isn't this working?
The line oSheet.Cells[row, column] = data; works correctly and it writes to incrementing columns and rows correctly, but I would like it to see if data contains a \\ and then make it a hyperlink if it does.
Thanks for reading.
oSheet.Cells[row, column] = data;
if ((data.Contains(@"\\")) && (createSheet == false))
{
oSheet.Hyperlinks.Add(oSheet.get_Range(row, column), data, System.Type.Missing, System.Type.Missing, data);
}
|
|
|
|
|
The main problem is the way you are adding the hyperlink.
Instead of Hyperlinks.add you could try Range.ApplyFormula .
Obviously you have to define the formula...
string filexl = @" C:\NewFile.xls";
Workbook wbnew = new Workbook();
Worksheet wsnew = wbnew.Worksheets.Add("New");
wsnew.Rows[0].Cells[0].ApplyFormula(@"=HYPERLINK(""http://www.codeproject.com"",""Urgentzzzz"")");
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC League Table Link
CCC Link[ ^]
|
|
|
|
|
Thanks, I will try this tomorrow
|
|
|
|
|
Hi Dalek,
As an update, I tried this, it does not work in my IDE. I have 2008 express .net 3.5.
I do not have an option for .ApplyFormula and my oSheet.Cells or oSheet.Rows have to be defined with [row, column].As an update,
|
|
|
|
|
URLs tend to contain forward slashes, not backslashes.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Do you know I looked at that and still didn't see it!
That gets an upvote for Olympic Standard Noticing
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC League Table Link
CCC Link[ ^]
|
|
|
|
|
Maybe you need polarizing spectacles?
Always see what is there and don't see what isn't.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hi Luc!
You are right, this is actually a UNC path
I believe it is still considered a hyperlink, but I may have used the wrong terminology, I used hyperlinks because of the c# method terminology.
|
|
|
|
|
Here is what works, thanks to all that contributed and answered
oSheet.Cells[row, column] = data;
string cell = oSheet.Cells[row, column].ToString();
if ((data.Contains(@"\\")) && (createSheet == false))
{
Excel.Range rng = (Excel.Range)oSheet.Cells[row, column];
oSheet.Hyperlinks.Add(rng, string.Empty, data, "", data);
}
|
|
|
|
|
Hi,
I'm new in DB programming in .net context and I have a question.
If I use a DB in my internet site (es www.mysite.org), I can quering this DB from my desktop application using ADO.net?
Thank a lot.
Alex
|
|
|
|
|
Yes, as long as the database server can be connected to remotely. If it can't be done that way, you can always create a web service to handle the access, and just connect to the web service instead.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
My 5! Good answer since it's most likely that the webserver is behind a firewall. A webservice is a good and viable solution.
|
|
|
|
|
If it's hosted then the database will be likely hiding behind a firewall. Yup, webservices are the way to go
I are Troll
|
|
|
|