|
Any plans to reopen the blog now?
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
how to run the style marquee? becoz i cant run watever i do.please help me
|
|
|
|
|
How to place an image in the range (cells[5,1],cell[10,5]) of excel? and how to make it in the center of the range?
thanks!
|
|
|
|
|
I hate Excel!
Don't you place the image in the value of Cell(5,1)
I would select the range
Set the vertical and horizontal alignment
Merge the cells
Then add the image
The above is a guess but it seems reasonable.
|
|
|
|
|
This is a wrong place to ask this question 
|
|
|
|
|
I need to use an incremental counter, by means of retrieving and updating a value stored in a text file
I know how to use the StreamWriter and the StreamReader classes but what I need to do is to read an int value from a text file, then increment the value by one and write it back to the file.
Is there a way to place a lock in the file while doing both operations? The reason for that is to avoid multiple concurency.
Also, how can the file be checked if it is locked?
Thanks,
CBenac
|
|
|
|
|
If all interested parties are instances of the same app which you develop, then you could base the protection on the FileShare parameter in File.Open(); this might fail if remote access and/or foreign file systems are involved. A few simple tests could be in order.
If all interested parties are threads in a single app, then you wouldn't need a file, just use Interlocked.Increment() on some variable. If need be, save/restore the value to/from a file on app exit/start.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Luc Pattyn,
The Interlocked.Increment() method is exactly what I need for the application.
Thanks so much for your sugestion!
CBenac
|
|
|
|
|
You're welcome.
May I suggest next time you explain your problem at a higher, more functional level. Apparently the file was a detour, and my gamble for interthread synchronization happened to hit the spot.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
|
Hello,
I have an odd problem. I have a couple of UserControls in my project, and a bunch of instances of them on my Form (with TabPages and other containers to avoid too much clutter). For the most part everything has been fine, but today I tried to modify the definition of one of the UserControls , and whenever I make that control visible on the form (i.e. switch to the TabPage containing it), I can only select controls on my Form from the drop-down list in the Properties page. If I try to click on the control in the designer, the Properties page does not update to show the selection. If I make any changes in the Properties page, those changes affect the last control that was properly selected. If I switch to a different TabPage or hide the control, then everything works fine again.
All I have done to the UserControl definition is remove some properties that I don't need anymore and add a couple of new ones. All the references in my project have been updated and it compiles just fine.
Any ideas? An hour or so of Googling has failed me today (unless my keywords aren't quite right). I've already tried restarting Visual Studio, restarting my computer, reverting to previous versions of the project (previous versions work until I start messing with the control definition), and someone had suggested deleting the contents of C:\Documents and Settings\User\Application Data\Microsoft\Visual Studio\versionNumber.
I am using VS2005 on XP Pro SP2.
Thanks,
Dybs.
The shout of progress is not "Eureka!" it's "Strange... that's not what i expected". - peterchen
|
|
|
|
|
Im not sure if this is bad programming or anything of the kind. But I need to be able to save a property of an object without know what the name of the property will be before hand.
I have an object: objUser, object user might have properties name, surname and age.
So I want to be able to say:
objUser.["Name"] = "Philip";
or
string sProperty = "Name";
objUser.[sProperty] = "Philip;
How do I invoke such a string as a property? (if explained correctly)...
Any help would be appreciated.
|
|
|
|
|
google for .NET reflection, and be warned it will be more complex than what you are hoping for.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Is this a class that you are designing? Or does it already exist and you can't change it?
If you are creating the class, you could design that in, perhaps by wrapping a Dictionary and providing an indexer rather than defining actual properties.
|
|
|
|
|
It is a class we made so I have access..Thanks will try that.
I can remember in old VB you could place a string in square brackets and it would convert it to a property...
|
|
|
|
|
Perhaps you could do something as simple as an indexer which contains a switch:
...
switch ( Property )
{
case "Name" : Name = value ; break ;
...
Unfortunately all the properties would need to be of the same type (at least object).
And you would have to maintain the indexer along with any added or removed properties.
|
|
|
|
|
One way, given you're using brackets anyhow, is to implement a map of property names to values inside the class. Way easier than a ton of reflection.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Key concepts: Reflection and public properties. What you're attempting is the same concept that .Net uses in data binding; i.e. string property "names" that are resolved at binding time. Getting back to your situation, consider this:
using System;
using System.Reflection;
namespace ConsoleApplication1 {
class Program {
static void Main( string[] args ) {
Person aPerson = new Person() { FirstName = "Phil", Age = 39 };
string propertyName = "FirstName";
PropertyInfo personProperty =
aPerson.GetType().GetProperty( propertyName );
// Displays: FirstName = Phil
Console.WriteLine( "{0} = {1}",
propertyName, personProperty.GetValue( aPerson, null ) );
}
}
public class Person {
public string FirstName { get; set; }
public int Age { get; set; }
}
}
|
|
|
|
|
In addition, use "SetValue" instead of "GetValue" to assign a value to your "named" properties.
|
|
|
|
|
Hello!
My intention is to write a program in C# that creates a database in SqlServer 2005.
For that reason I use SqlServer 2005. In a specific directory I have serveral Sql Script written in TSQL that creates tables and stored procedures. As I can see in debug mode in Visual Studio 2008 all characters in theese files is read correctly.
I'm from sweden so we have our specific character Å, Ä and Ö.
When I have read the TSQL script into a variable I want to execute the ExecuteNOnQuery(script) method in the smo API. My table will now be created in the database but the character Å, Ä and Ö is missing!!!
I wan't a solution for this problem quickly!
Maybe somebody has experience of smo, sqlserver and C#.
Best regards
|
|
|
|
|
Håkan Axheim wrote: I wan't a solution for this problem quickly!
*grin* of course you do.
Is your database set up to have a character set that includes those characters ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Yes our database is correct installed so this character set will be supported.
|
|
|
|
|
When I press a button (soft key on touch screen, or key on mobile device) I want to disable all other events from other buttons for a certain time. For example when I press Button1, I want Button1, events to be ignored for a few seconds, and then be active again. I have tried Button1.Enabled = false; if I press Button1 while it is disabled, when I re-enable it, the events still occur.
private void Button1_Click(object sender, EventArgs e)
{
Button1.Enabled = false;
textBox1.Text = "Button1 Pressed";
Thread.Sleep(Time);
Button1.Enabled = true;
}
How can I keep these events from occurring while the button is disabled?
|
|
|
|
|
I'd imagine you need a timer and a flag which is checked inside all the other events.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Sorry, I'm new to C# so please forgive the ignorance...
I have a list, and want to make another list from the first list:
int[] list1 = { 1, 3, 5, 7, 9 };
int[,] list2;
for (int i = 0; i < list1.Length; i++)
{
list2[i] = [item from list1] , [i];
}
How do i put items in list2? I'm looking for:
{{1,0} {3,2} {5,3} {7,4} {9,5}}
Thank you for your time.
|
|
|
|