|
Hello,
I'm a c#.NET developer and I want to have a toolbar control in my application that has a transparented background. Can I do it? I know that the toolbar doesn't support the transparented BackColor property. Is there another way to do it?
Thanks
|
|
|
|
|
Maybe you can try creating a custom toolbox control using group boxes or panels. Both support transparency.
|
|
|
|
|
I think it will be to complicated, no? Isn't there a better way? Maybe there's a free control that I can download that will do it for me?
Thanks lj_rules for you answer - I really appreciate this
|
|
|
|
|
Hello,
I am using a datetime variable. But l want to change the format of the shortdatestring from mm/dd/yyyy to the new format of dd/mm/yyyy.
I used the code below using, using System.Globalization. However, it won't change to this new format of dd/mm/yyyy
DateTime today = Convert.ToDateTime(DateTime.Today.ToShortDateString());<br />
DateTimeFormatInfo dateFormat = new DateTimeFormatInfo();<br />
dateFormat.ShortDatePattern = "dd/mm/yyyy";<br />
today.ToString(dateFormat);
Can anyone help with this.
Many thanks in advance,
Steve
|
|
|
|
|
Here is how is goes:
DateTime today = DateTime.Today;
MessageBox.Show(today.ToString("dd/MM/yyyy"));
Regards.
|
|
|
|
|
I have created a class that inherits from ListView and a class that inherits ListViewItem and implements IComparable. If I put the items in an ArrayList and Sort the items are sorted correctly, but when i try to use Sort in the ListView it doesnt do anything. I´ve tryied invoking the sort part in the listview but no that doesnt work. I do not want to create a class for the sorting part so i thought that IComparable only on the objects in the collection would allow me not to modify the collection. Is there something im missing???
|
|
|
|
|
ListView needs an IComparer to be assigned to the ListViewItemSorter property, for the sorting work.
Read the help on the Sort property on MSDN for a sample, if your class already implements IComparable, you can simply delegate it to the CompareTo() method, and code the IComparer with one line of code only.
And that, IMO is a design mistake, and should be done by the ListView by default.
Yes, even I am blogging now!
|
|
|
|
|
I had a problem earlier about constructing sockets in win2k, that I managed to resolve. However, further down the code, I suffered from an additional problem with Permission Exceptions. I have the following error message (It's a bigun!):
System.Security.SecurityException: Request for the permission of type System.Net.SocketPermission, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=<token> failed.
at System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet grantedSet, PermissionSet deniedSet, CodeAccessPermission demand, PermissionToken permToken)
at System.Security.CodeAccessSecurityEngine.Check(PermissionToken permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32 checkFrames, Int32 unrestrictedOverride)
at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark)
at System.Security.CodeAccessPermission.Demand()
at System.Net.Sockets.Socket.CheckCacheRemote(SocketAddress socketAddress, EndPoint remoteEP, Boolean isOverwrite)
at System.Net.Sockets.Socket.SendTo(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, EndPoint remoteEP)
at System.Net.Sockets.Socket.SendTo(Byte[] buffer, Int32 size, SocketFlags socketFlags, EndPoint remoteEP)
at Ping_Library.Ping.PingHost(String host) in \\<file location="">:line 197
I tried adding unrestricted socket permission to it using the following line:
<br />
SocketPermission se = new SocketPermission(<br />
System.Security.Permissions.PermissionState.Unrestricted);<br />
This failed to fix the issue. Does anyone know how to resolve this?
Cheers
Tris
|
|
|
|
|
Lets say I have following event handler
private void PrintDocument_PrintPage(Object sender, PrintPageEventArgs e)
{
/// some code
}
If I open a watch window on "sender" or on "e", some of the items in watch window get duplicated, like;
"defaultPageSettings" and "DefaultPageSettings"
or
"DocumentName" and "documentName" , etc;
except the first letter's case they have everything common.
What is the reason to provide the same data twice? There must be some...
Please guide.
|
|
|
|
|
Those are duplicates. One is the private field and the other is the public or protected property that exposes the field. Notice the difference in case? The .NET Framework is case-sensitive (despite what you hear about VB.NET, in which case it's only "case-insensitive" because the source editor corrects the case for you at design-time).
Fields should never be exposed publicly, except perhaps for constant values. One common naming convention is for the private fields to use a lower-case letter in the first position while the property that reflects it uses the upper-case notation that is a guideline in the .NET Framework (unlike Java, in which case all members start with a lower-case letter; consistency is very important in Rapid Application Development (RAD) environments).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi ALL.
Is there any legal or technical limitations in publishing .Net Beta 2.0 applications?
Yaakov
|
|
|
|
|
There is a license.txt file in the SDKs after you download and install them. The best way to understand the legal limitations is to read them or have a lawyer read them.
As far as technical limitations, there really aren't any more than any other language. ".NET" is actually Microsoft's implementation of the Common Language Infrastructure (CLI), and only runs on Microsoft Windows platforms (except 9x, which is not supported any more). There are other CLI implementations for other platforms, including Mono, Portable.NET, and dotGNU.
When you use a full-featured language that targets the CLR (Common Language Runtime) like C# (written from the ground-up for .NET and it is an ECMA standard, unlike other languages *cough* VB.NET) there really isn't much you can't do. C# and other managed languages let you call native functions. C# also allows you to use unsafe code (i.e., direct memory addressing and pointer math with pinned memory).
Once again, the best way to understand the limitations is to read. In this case, be sure to read through the .NET Framework SDK, which is installed by default with VS.NET, available separately as an SDK install, and available online at http://msdn.microsoft.com/library[^]. For 2.0 beta, you'll want to visit http://msdn2.microsoft.com/library[^]. I'll warn you that a lot is not documented publicly yet so the latter reference may not be a lot of help.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks for your detailed answer.
Yaakov
|
|
|
|
|
How do you create a stand alone static enum (I guess class) that can be accessed through it's Namespace. Like for instance....
Like in the Namespace System.Data the enums
ConnectionState
CommandType
DataRowAction
In these instances when I want to check a connection's state I compare my connection object's State property to (With no using statement) System.Data.ConnectionState.Open
How do I create a custom enum class inside by Namepsace that I can reference directly without having to reference through a created object?
Thanks for the help!
Trevor Ledet Newbie.
|
|
|
|
|
I'm not sure I understand what you're asking, but you don't have to reference an enum through an object: in fact, System.Data.ConnectionState.Open includes no objects - only the namespace (System.Data ), then the enum (ConnectionState ), and finally the enum member (Open ). It isn't like many C/C++ enums that are just #defines.
You declare an enum like so:
public enum MyEnum
{
One,
Two,
Three
} You can also assign specific values to each. If you want to use a flagged enumeration (so you can use bitwise operators on the enum members), attribute it with the FlagsAttribute and - to following naming guidelines to be consistent with the base class library (BCL) - make the enum plural:
[Flags]
public enum MyEnums
{
One = 1,
Two = 2,
Four = 4
} For more information about this, I highly suggest you read about the Visual C# Language[^], especially the Visual C# Language Specification[^].
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I did not realize I could declare a enum in the namespace outside any class being defined in the namespace. But it works.
Thanks for the help.
|
|
|
|
|
hello i am having tons of trouble moving a child window where i want if the user click within that child i want to keep the cursor at the same location on the child however i want to be able to drag the child around basicly i want to keep the mouse at the same position on the child and be able to move the child relative to the form
here is the code im working with
<br />
private void gripper1_Click(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
dragging = true;<br />
this.Dock = System.Windows.Forms.DockStyle.None;<br />
<br />
Point p1, p2;<br />
p1 = PointToClient(new Point(e.X, e.Y));<br />
p2 = PointToClient(Location);<br />
diff = new Point(p2.X + p1.X, p2.Y+p1.Y);<br />
}<br />
<br />
private void gripper1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
if(dragging)<br />
{<br />
this.Location = PointToScreen(new Point(e.X + diff.X, e.Y + diff.Y));<br />
}<br />
}<br />
i have tried every combination of adding and subtracting and PointToScreen and PointToClient
however none work this is the closest it sometimes keeps the pointer within the child but it seems inconsistant please help this is my 3rd post and none of the solutions that have been offered actualy work. PLEASE PLEASE PLEASE HELP ME!
|
|
|
|
|
No need to fumble with Screen or Client coordinates. Its all a question of relative distances so your absolute zero really doesnt matter.
See if this works any better. Haven't tested it, but logic says it should work :p (Contrary to what I said above the code includes some Screen / Client coordinates but its not strictly necessary. The sole purpose is to make everything a little fancier detecting when ur trying to move the child form out of it's parent window)
Point mouseDownPos;
protected override void OnMouseDown(MouseEventArgs e)
{
mouseDownPos=Cursor.Position;
Cursor.Clip=new Rectangle(this.MdiParent.PointToScreen(this.MdiParent.ClientRectangle.Location),this.MdiParent.ClientRectangle.Size);
this.Capture=true;
}
protected override void OnMouseMove(MouseEventArgs e)
{
if (this.Capture)
{
Point mousePos=Cursor.Position;
Rectangle rec=this.MdiParent.ClientRectangle;
int cx=mousePos.X-mouseDownPos.X;
int cy=mousePos.Y-mouseDownPos.Y;
this.Location=new Point(this.Left+cx,this.Top+cy);
mouseDownPos=Cursor.Position;
}
}
protected override void OnMouseUp(MouseEventArgs e)
{
Cursor.Clip=new Rectangle(0,0,0,0);
base.OnMouseUp (e);
}
Hope it helps
|
|
|
|
|
i tried your code but nothing act6ualy happens
|
|
|
|
|
I just tried it and apart from making a small change to make the cursor clipping a little better everything works fine.
P.D. The code is supposed to be implemented in the child form, not in the parent. And of course, I've tested it with an empty form, if ur form has controls, then it wont pick up the mouse events and the code wont do anything. U seem to link the mouse events to an object called gripper. Link the your gripper mouse events instead of the Form's overrides if your form isnt picking up the mouse events.
|
|
|
|
|
read my previous response please
|
|
|
|
|
actualy i just changed capture to my dragging and it worked however the mouse position does move slightly in relation to the form when i drag it around alot but for the most part it works how i want it to any ideas how to prevent the mouse from drifting off?
|
|
|
|
|
I'm not experiencing any mouse drif but I'm testing this with an empty form. If your form has controls that could intercept mouse events and therefore not reaching the form hanlders, it could be cause of a small drift. I'm not too sure about it though.
Check that, I dont think that could be the cause. The only sympton would be that depending where u click, the form would capture the mousedown and move or it wouldn't do anything.
What is ur form's control layout if any?
|
|
|
|
|
atm it the form inherats a base class that is a form with a custom gripper control the gripper is the thing actualy is reciving my mouse click and mouse move message the mouse seems to drift when i move the mouse really fast or when i move the window beyond the edge of the visible screen and yes i do have docked control in my parent
what i am trying to do is create my own docking windows so far its going well except for this mouse positon stuff :p
|
|
|
|
|
hey on a similar topic how would i determine whether or not my child is at or beyond the parents rectangle
if(this.ClientRectangle.Top <= this.MdiParent.ClientRectangle.Top)
MessageBox.Show("Hi");
i tried this but it always message boxs me no matter where i drop the form
|
|
|
|