|
Hi,
Can You please Tell me what is the difference between 'byte' and 'Byte' as a datatype in C#
thank you.
|
|
|
|
|
No difference really, just different names for the same thing.
'byte' is just short for System.Byte. It's a primitive so has shortened form.
Regards,
Rob Philpott.
|
|
|
|
|
|
|
Byte is NOT a wrapper for byte.
'byte' is a C# keyword that is a synonym for 'System.Byte'.
In computing, the word 'Wrapper' has a different meaning.
|
|
|
|
|
You are confusing with java. in C#
byte == Byte
string == String
...
...
..
..
|
|
|
|
|
None. One's a synonym for the other.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
The only difference is when defining an enumerated type; byte and the other aliases are allowed, but System.Byte etc. are not.
|
|
|
|
|
you know, select a tree node, it would be highlighted with blue color, if the tree lose focus, the color would be gray, it's hard to know which one is selected, is there a good way to change the gray to a light color? Or need to redraw the node?
if need to redraw the node, there would be many works need to do, like restore the node etc.
Is there a good sample to show this?
Thanks you!
|
|
|
|
|
Did you change the color of the TreeNode.
Also dont forget to call TreeView.Invalidate() method to force tree view to repaint.
|
|
|
|
|
|
Set HideSelection to false. When the TreeView does not have the focus, the selected node will be displayed in a light gray shade. If you want to change that, you need to have an owner drawn TreeView.
|
|
|
|
|
Yes, I have set HideSelection to false, but the gray color is too white, it's hard to see.
Is there a sample to show how to redrawn the Treeview? Or is there a easier way to resove it?
|
|
|
|
|
Just google "Owner draw TreeView in .NET"
|
|
|
|
|
I´m developing a Windows Forms app with C# 2003. Well, I´ve got a DataGrid control with 2 Date columns with "dd/MM/yyyy" format...the trouble is that when I click that columns' headers they get obviously sorted by day, then month, and then year (01-02...30,31)...and I want them to get sorted by year, then month and then day...I´ve placed this code on the datagrid_mouseup event...so when the datagrid sorts the column it will do it correctly...but I don´t know how to revert back the date format, because the sorting method seems to be internal and performed after all other DataGrid´s events are processed. So how could I know when DataGrid has finished sorting to put the dates into their former format? (or other way of doing it, of course). Thanx.
<pre>
DataGrid.HitTestInfo hitTestInfo = myDataGrid2.HitTest(myDataGrid2.PointToClient(Control.MousePosition));
if (hitTestInfo.Type==DataGrid.HitTestType.ColumnHeader)
{
if ((hitTestInfo.Column==2)||(hitTestInfo.Column==3))
{
for (int i=0;i<Avisos.Rows.Count;i++)
{
DateTime myDateTime = DateTime.ParseExact(myDataGrid2[i,hitTestInfo.Column].ToString(),"dd/MM/yyyy",null);
myDataGrid2[i,hitTestInfo.Column] = myDateTime.ToString("yyyy/MM/dd");
Application.DoEvents();
}
}
}
</pre>
modified on Thursday, November 26, 2009 6:32 AM
|
|
|
|
|
HI,
Your code looks evil. Application.DOEvents() is a bad call.
Re-think and do this in a different way and not with a hit test ??
How much data is on this grid ?
|
|
|
|
|
Forget that order. I´put it there just to place a breakpoint over it...but...why Application.Doevents is "evil" as you say?
If I found a better option (or an option that could work, at least) be sure that I will take it .
We are talking about 200 records more or less.
|
|
|
|
|
Hi,
As you can see in other responses, Application.DoEvents consumes all kinds of events such as user clicking buttons and can cause unexpected application states. It can also be a very heavy call to make in a loop, since you do not really know what or how much code will be executed. I am not saying never use it but use with extra caution (try not to use it).
I asked for the number of records since you can use a list view in which sorting is very simple. Sorting list view C#
|
|
|
|
|
Much easier. Thanx!
|
|
|
|
|
|
DataGridView control is in Framework 2.0+, not in 1.1 with which I´m developing this App.
|
|
|
|
|
Sorry
|
|
|
|
|
Hi.
I'm having a problem with conflicting namespaces and code that gets autogenerated by the forms designer in Visual Studio 2008. I have search many forums and different documentation, but have not been able to find any solution to this problem.
I have one assembly called Foo.dll with the following namespace/code:
namespace Foobar.System
{
public class MySystemClass() { }
}
Then, I have another assembly which contains som commonly used forms:
namespace Foobar.MyCommonForms
{
public class MyForm : System.Windows.Forms.Form
{
public void SomeMethod()
{
var systemclass = new Foobar.System.MySystemClass();
}
}
}
Here, the compilers display the following error: Type or namespace 'Windows' is not part of namespace 'Foobar.System'. Obviously, the compiler tries to look for the class System.Windows.Forms.Form in namespace Foobar.System.Windows.Forms!
I have been able to solve this by using the alias 'x' instead of 'global' when referencing to the assembly Foo.dll, and declaring extern alias x in my code files, and put 'x::' in front of every reference to types and classes in the namespace Foobar.System. The code compiles.
But it seems that the forms designer don't recognise this, and gives me an error when trying to display the form. This, again, can be solved by manually putting 'global::' in front of every reference to classes in System.Windows.Forms (e.g. global::System.Windows.Forms.Button ), but every time chances are made to the form, the code is automaticaly re-generated, and the 'global::' part is removed.
So, the question is: Is there a way to make the forms designer aware of the alias 'x' that is used to reference my assembly Foo.dll, or is there another, better solution to this? Renaming the namespace Foobar.System to something else is just too much work.
|
|
|
|
|
hi, this sounds realy heavy to me,
but i think you can change the namespace at the project properties to solve the problem.
maybe all namespaces in classes will be renamed (think i saw some like that)..
i think the problem is that the projects name namespace is written in has the same name as the assembly namespace so the windows forms designer implicit thinks that the System namespace comes from YOUR assembly not from microsoft..
i might think totaly wrong but i thought i try to help you with an idea
greetz
|
|
|
|
|
You've got something seriously screwed up in your project. The compiler cannot look for System.Windows.Forms in your namespace. I don't know what to tell you because I can't even replicate the problem in a test project with what you've posted. What are the namespace properties of the project? What namespaces are you importing at the top of the code for each of these??
|
|
|
|