|
Huh, that is odd. The documentation doesn't say it won't work for structs, the closest statement to that is:
"
To use the SetValue method, first get a Type object that represents the class.
"
Does this mean it only works for classes?
|
|
|
|
|
Well, technically it IS setting the value, the only problem is that it is setting the value on a copy of the struct passed in, so the changes are lost the instant the SetValue method returns. Oh well, at least I got it to work. Thanks,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
I was looking for a program that would output to the port and found Levent Saltuklaroglu’s I/O Ports Uncensored - 1 - Controlling LEDs with Parallel Port. It’s a great program, works nice.
I've been playing with the source code he uploaded with it to get a slightly different outcome from some of the buttons. Turns out, I haven't been able to compile it, not even his original code. I get an error message "missing partial modifier on declaration of type 'led.form1'; another partial declaration of this type exists". I was hoping someone could help me with this.
I'm using Microsoft Visual Studio C# 2008 express edition. I've also copy and pasted his code into a new Windowsformapplication1 window.
Is there a better way?
|
|
|
|
|
highly doubtful his project was written in 2008, probably 2003, before partial classes existed. Sounds like VS2008 has created the partial class for control autogenerated code, try just adding the word 'partial' before the word 'class' ( or perhaps after ) and see if it compiles.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi
I have problem with data table in C#.In the code below i have data table which contains some values. "dt" is DataTable object and "dr" is DataRow[] object. when i fire some query on datatable using select method, it returns some datarows which fulfill the expression. And when i modify any column value of datarow like column "ID" it also modifies the values in datatable dt.
Can you tell me why this is happening? I don't want to modify values in datatable dt.
Thank you.
Class prog
{
static void Main(string[] args)
{
dr = dt.Select(expression);
dr[0]["ID"] = 10;
}
}
|
|
|
|
|
dalbhide bipin,
The datarow references the datatable, so they are "one". Why are you trying to only edit the datarow and not the table? eg: What are you doing?
Regards,
Gareth.
|
|
|
|
|
|
I am instianting an array of MyControl but after instianting my mc[0] is null. I don't understand it. shouldn't it has Width 100 and Height 100
MyControl[] mc = new MyControl[5];
public class MyControl:Control
{
public MyControl()
{
this.Width=100;
this.Height=100;
}
}
Thanks
|
|
|
|
|
You've instantiated an array to hold 5 MyControl s. You still have to instantiate the controls and add them to the array.
/ravi
|
|
|
|
|
try
MyControl[] mc = new MyControl[5] { new MyControl(), new MyControl(), new MyControl(), new MyControl(), new MyControl() };
that will allocate an array of MyControl instances and then also initialize the array slots.
Silence is the voice of complicity.
Strange women lying in ponds distributing swords is no basis for a system of government. -- monty python
Might I suggest that the universe was always the size of the cosmos. It is just that at one point the cosmos was the size of a marble. -- Colin Angus Mackay
|
|
|
|
|
hi to all.
I m creating website blocker and i don't have any idea that how to this.
can anybody send me information about this or link in C# or any algorithm
thanks to all
|
|
|
|
|
One way to do this is to programatically edit the hosts.txt file, althought that's a really cheesy solution.
A better way would be to intercept network traffic (like a firewall) and selectively allow connections. Or, you could leverage the Windows firewall - see this[^] article.
/ravi
|
|
|
|
|
Mahmood Abbasi wrote: hi to all.
I m creating website blocker and i don't have any idea that how to this.
can anybody send me information about this or link in C# or any algorithm
thanks to all
Why would we do that? You need to learn how to break the problems down for yourself - you need to be able to analyse items and do research for yourself. If you don't have any idea how to do this, why would you want to tackle such a complex area? I'm not asking this to be nasty - I'm just curious as to why you're wanting to do this.
|
|
|
|
|
well u said that if it is difficult then y r u doing this. SO friend if this was not difficult then y i aske people for help .
And about ur second question so i must do this,because i m student and its my semester project . So its unable to leave it.
How to block network IP's or Web site in C# if anybody knows or any body have some peace of code send me .
thanks 2 every body.
|
|
|
|
|
Please learn English. ur is not a word.
If it's your semester project then either you chose it, and should have chosen something you knew how to do, or you were given it, in which case you have materials to tell you how to do it. We'd love to help if you have specific questions, but not if you want to be told how to do your project from the top down.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
look at http://www.privoxy.org/
It's not C#, but it'll get you something to look at to get an idea of where to start.
Good luck.
Silence is the voice of complicity.
Strange women lying in ponds distributing swords is no basis for a system of government. -- monty python
Might I suggest that the universe was always the size of the cosmos. It is just that at one point the cosmos was the size of a marble. -- Colin Angus Mackay
|
|
|
|
|
All of us have probably ran into this before. You disable a control for some reason or another and would like to let the user know what they did to make this control turn grey or what they can do to enable it again. Sadly, doing it with a tooltip in one or two lines of code is right out because the OnMouseEnter method checks the ButtonBase state for certain flags before rendering the tool tip.
I tried dancing with this problem today by overloading the CheckBox control and forcing the OnMouseEnter function to fire. I realized, then that I had to overload ButtonBase as well.
Not wanting to rewrite an entire class in the framework, I decided to use the old fallback of using the MouseMove event and checking its location.
That was my solution for this today. Anyone ever find a better solution? I hear WPF has built in support for this sort of thing.
|
|
|
|
|
Tooltips seem to render fine for me on disabled controls.
/ravi
|
|
|
|
|
Hmm, are you running 3.0? If so, that's one more reason to migrate.
|
|
|
|
|
|
How is that possible unless you have custom code. From msdn for 3.5:
ToolTip text is not displayed for controls that are disabled.
|
|
|
|
|
i am hoping this is an easy one. Is there an objective advantage to using a double of float, or vice versa?
I have a project that requires precision to 4 decimal places, so it seems like it is an either/or question, where neither would have a clear advantage over the other, but I was wondering if someone was familiar enough with the inner workings of the two types to say one is better than the other.
I am leaning toward double, since i have used it quite a bit in the past, but wanted a second opinion before going too far.
Looks liek i messed up, it should be decimal, not float. same question though.
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
If you need a given precision, I would go with Decimal. Double are not precise numbers.
|
|
|
|
|
Vodstok wrote: requires precision to 4 decimal places
Four places total?
What's the range of values you need to cover?
I'm no expert on it, but the C# spec says:
"
The float type can represent values ranging from approximately 1.5 × 10^-45 to 3.4 × 10^38 with a precision of 7 digits.
The double type can represent values ranging from approximately 5.0 × 10^-324 to 1.7 × 10^308 with a precision of 15-16 digits.
The decimal type is a 128-bit data type suitable for financial and monetary calculations. The decimal type can represent values ranging from 1.0 × 10^-28 to approximately 7.9 × 10^28 with 28-29 significant digits.
"
Unfortunately, when people tried to explain it to me in the past they simply said things like
"A float is precise to seven decimal places" which is not exactly correct and rather misleading.
|
|
|
|
|
Double is the floating point representation that is natively supported by tbe processor. It supports precision way beyond your requirement, but floating point numbers still have limited precision. Some numbers can't be represented exactly, so a number like 1.2345 might be stored as 1.234499999999999238. It's rounded off inside the precision when represented as text, so you normally never see the precision limitations.
Decimal is a fixed point number. It's twice the size of a double and not directly supported by the hardare, so calculations are a bit slower. As it's a fixed point number it supports exact precision, i.e. a number like 1.2345 is stored as the integer 12345 with a four digit decimal point shift.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|