|
You can create such a button by setting the ControlStyles.Selectable value to false.
This is a sample of how to do it (#using directives omitted):
public class InertButton : Button
{
public InertButton()
{
SetStyle(ControlStyles.Selectable, false);
}
} That's it.
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
i´m develop a local and remote application with sqlServer, the connection path where i´ve ip address, database, user and pass its on xml file, with two differents tags <local> and <remote>, and my question is, how its better, a class user with and attribute state , 0 local ,1 remote and when i use the class DataBase management if (i==0){read XML Local}else{read XML remote},or use a factory ?? and it i use a factory how can i do???
thanks for all
see you soon
|
|
|
|
|
I need to write some decimals on magnetic medium.
A C# decimal is realized in memory as series of 16 bytes.
How can I, without unsafe mode, code the conversion from deciamal into such an array byte[] and backwards?
HilSoft
|
|
|
|
|
If you use Reflector, you can see what the underlying implementation is for Decimal . For instance, there's an internal method called GetBytes that looks like this:
internal static void GetBytes(decimal d, byte[] buffer)
{
buffer[0] = (byte) d.lo;
buffer[1] = (byte) (d.lo >> 8);
buffer[2] = (byte) (d.lo >> 0x10);
buffer[3] = (byte) (d.lo >> 0x18);
buffer[4] = (byte) d.mid;
buffer[5] = (byte) (d.mid >> 8);
buffer[6] = (byte) (d.mid >> 0x10);
buffer[7] = (byte) (d.mid >> 0x18);
buffer[8] = (byte) d.hi;
buffer[9] = (byte) (d.hi >> 8);
buffer[10] = (byte) (d.hi >> 0x10);
buffer[11] = (byte) (d.hi >> 0x18);
buffer[12] = (byte) d.flags;
buffer[13] = (byte) (d.flags >> 8);
buffer[14] = (byte) (d.flags >> 0x10);
buffer[15] = (byte) (d.flags >> 0x18);
}
You could use reflection to call that internal method or you could use GetBits and convert the integers to bytes yourself. Here's what GetBits looks like:
public static int[] GetBits(decimal d)
{
return new int[] { d.lo, d.mid, d.hi, d.flags };
}
To convert the bits back into a Decimal , you can use the constructor that takes an int array. The array is in the same format that is output by GetBits .
Logifusion[^]
|
|
|
|
|
I do not know what is Reflector,
and what the function .lo .mid and so on
My Visual Studio 2005 does not understand such kind of things.
But thank you, anyway. I'll try...
HilSoft
|
|
|
|
|
Reflector is a tool that decompiles IL and shows the (approximate) source that was used to create it. lo, mid, etc are private members of the Decimal class.
http://www.aisto.com/roeder/dotnet/
|
|
|
|
|
Even if it is so, I have no rights to use any private members of the Decimal class. The code will be aborted.
HilSoft
|
|
|
|
|
The public GetBits method returns the internal contents as 4 ints. The reflected code shows how the data goes into them. You can then bust the ints into seperate bytes for your own purposes. Alternately using features provided in the System.Reflection namespace you can access and use the private GetBytes method the same way Reflector does.
|
|
|
|
|
Thank you very much, Dan. As I understood you, I can write:
int[] ints4= Decimal.GetBits(dec);
And then I can put each "int" of the ints4 into corrspondent part of an 16-byte-array.
As I know, I can use for the purpose the BitConverter function. Isn't it?
I've wrote
using System.Reflection;
but I do not know what to write on...
(The Reflector.zip I've downloaded from Lutz Roeder. Thank you, it is useful).
And the Problem remains - how to OBTAIN decimal even if I have the ints4 (the backwards task).
-- modified at 16:21 Thursday 27th July, 2006
|
|
|
|
|
decimal d = new decimal(1234.5678);<br />
byte[] b = System.Text.Encoding.UTF8.GetBytes(d.ToString());<br />
string s = System.Text.Encoding.UTF8.GetString(b);<br />
d = Convert.ToDecimal(s);
only two letters away from being an asset
|
|
|
|
|
It's fantastic! Thank you.
But I'm not too fond to use such kind of heavy operations like converting to strings and bachwards.
It is much better than to be asset, but is far from natural.
Thank you, anyway!
HilSoft
|
|
|
|
|
I am new in C# and nobody could clarify this:
Yesterday I created some kind of an observer pattern
I created a delegate and two combo boxes, in one I set an event for changes using the delegate and in the other one I "listen" to that event. This works great, whenever the cahnge occurs in the first combo, the second one adjusts itself accordingly. The problem is if I didn't set a listener yet I get a null object exception for the line where I fire the event. Is this normal or am I doing something wrong ? To solve the problem I verify first if the object is null but I want to be sure I am not doing something stupid
Here is the code (useless lines removed)
public class CountryCombo : ComboBox
{
public event CountryChangedHandler countryChanged;
...code
public CountryCombo() : base()
{
...code
this.Leave += new EventHandler(CountryCombo_Leave);
this.BindingContextChanged += new EventHandler(CountryCombo_BindingContextChanged);
}
void CountryCombo_BindingContextChanged(object sender, EventArgs e)
{
this.countryChanged(SelectedValue.ToString()); //********* This where the error occurs if no listener
//********* this.countryChanged is null
}
void CountryCombo_Leave(object sender, EventArgs e)
{
if (this.SelectedIndex == -1 | this.SelectedIndex == 3)
{
this.SelectedIndex = 0;
}
this.countryChanged(SelectedValue.ToString());
}
}
public delegate void CountryChangedHandler (string countryISO3);
public class ProvinceCombo : ComboBox
{
...code
public ProvinceCombo(CountryCombo combo) : base()
{
combo.countryChanged += new CountryChangedHandler(ChangeCountry);
...code
}
public void ChangeCountry(string iso3)
{
...code
}
}
|
|
|
|
|
~~~Johnny~~~ wrote: To solve the problem I verify first if the object is null but I want to be sure I am not doing something stupid
Nope, it's not stupid. It's what you're supposed to do. Check if countryChanged is null before firing an event on it.
Logifusion[^]
|
|
|
|
|
Can you summerize the logic behind that?
|
|
|
|
|
You declare this:
public event CountryChangedHandler countryChanged;
countryChanged becomes a field in your class. But what does it store? Behind the scenes, countryChanged is actually a reference to a linked list of delegates that subscribed to the event. Initially, the field references null because there are no subscribers. The delegate CountryChangedHandler is actually an item in a linked list, meaning that within it is a pointer to the next item. So, when you subscribe to the event, a new CountryChangedHandler is created and added to end of the linked list. The reason Microsoft decided to do this was because it's a very efficient way to manage all the subscribers to a particular event. What it means for us is that you have to check if the event field is null before firing.
Logifusion[^]
|
|
|
|
|
Well, that couldn't be clearer, it gives me a good understandidng of what is actually happeneing.
Thanks a lot for your help
|
|
|
|
|
Hi
What is the activex control name for PivotTable and SpreadSheet?
I want to use them in a Windows Form Application
is it Microsoft Office Web component?
-- modified at 12:54 Thursday 27th July, 2006
|
|
|
|
|
Is it possible to overload a function from VS2005 IDE?
If so, I want to overload graphics.drawline() which signature in CF is drawline(pen, int x1, int y1, int x2, int y2). I want to change it to drawline (pen, point A, point B).
Any help?
Donkaiser
|
|
|
|
|
er, that overload already exists!
(in class System.Drawing.Graphics)
public void DrawLine ( System.Drawing.Pen pen , System.Drawing.Point pt1 , System.Drawing.Point pt2 )
|
|
|
|
|
Sorry! it's for CF. this overload is missing. But my point is to see if it's possible to overload IDE methods.
|
|
|
|
|
Whats an IDE method?
Either 2.0 or 3.0 ( idk which ) has a method for adding additional methods to a class. If you do a web search for new features of the two it can direct you. If those are not available the pattern is a wrapper class.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
Im using .net 2.0. googling around still haven't found anything yet.
Donkaiser
|
|
|
|
|
Its extension methods and I think it is in 3 only. Looks like you need a wrapper class.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
Yeah, I don't think it's possible to overload a native method. and the only solution is to do a wrapper.
Donkaiser
|
|
|
|
|
Hi,
I was hoping if someone could help me with this problem. I want to edit
datagrid entries without using a linkbutton column for edit and update.
maybe we could do this using javascript. But I dont know how?
On an 'edit settings' button click outside the datagrid, the cells in the datagrid should change into dropdownlists and textboxes with earlier values maintained.
Thanks!
Monisha
-- modified at 10:50 Thursday 27th July, 2006
|
|
|
|