|
Yes. It works perfectly. And it's very obvious... now that you point it out!
led Mike comes through again! Thank you.
|
|
|
|
|
Hi
I am using Visual Studio 2005 to create a Windows Application. I am struggling to move controls at runtime using the mouse.
I works fine when the Control (panel1) is directly on the Form, but when the Control is on another panel (panelGrid) on the Form it does not work well.
I use the following for the MouseMove event:
private void Control_MouseMove(object sender, MouseEventArgs e)
{
Control control = (Control)sender;
if (dragging)
{
Point location = new Point(e.X, e.Y);
location = control.PointToScreen(location);
location = PointToClient(location);
location.Offset(dragOffset);
control.Location = location;
}
}
When the Control is on another panel and not directly on the Form it jumps when I start moving it with the mouse.
I think it is probably the following lines that needs to change:
location = control.PointToScreen(location);
location = PointToClient(location);
I tried the following but it made it even worse:
location = control.Parent.PointToClient(location);
Can anyone throw some light on this for me please.
Thanks
Kobus
|
|
|
|
|
Using VS2005 on Vista...
I have the following
#if DEBUG
System.Diagnostics.Trace.WriteLine("block of code starts");
#endif
code
code
more code
#if DEBUG
System.Diagnostics.Trace.WriteLine("block of code ends");
#endif
Sometimes, both trace statements show up in the output window, sometimes they don't. The code in between does not present an early exit point of any kind, so I fully expect both trace statements to be displayed.
Is there something dodgy about .Net's ability to trace?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi,
A while ago I experienced the same kind of problem. In my case it was because two different threads affected each other, eventually blocking trace window once in a while (this might not be true in your case).
However, I created my own trace listener which only collected trace messages to a static generic list and used lock in order to prevent lost messages.
Hope that this helps you,
Mika
|
|
|
|
|
John Simmons / outlaw programmer wrote: #if DEBUG
If you are trying to execute in Debugging session use System.Diagnostics.Debug.WriteLine etc. Tracing is a different purpose altogether. I don't know if this will solve your problem, I'm just saying.
led mike
|
|
|
|
|
I have xml file like;
<Service>
<argument>12345</argument>
<interval>500</interval>
<source>test1</source>
<source>test2</source>
<source>test3</source>
<Service>
How can i remove selected "source" node. For example; I list the value on listbox, user select test2. How can I delete "test2" node in xml file.
Best Regards...
|
|
|
|
|
Assuming you loaded the file into an XmlDocument and populated the ListBox with the source nodes...
doc.DocumentElement.RemoveChild ( listbox.SelectedItem ) ;
Then save the file again.
I haven't tried it, but I hope that's not too far off.
|
|
|
|
|
I need some help getting a date range of 30 days Including the current date to display in a list view box. The first line would displays today's date, the second would display tomorrows, so on and so forth. In the end the second column in the list box would display an event that was set to trigger that day. you will be able to double click the date and setup or edit the event on that day. But the events themselves will be handled by another function. This is just purely to see the next 30 days (Because we'd never have more than that.) And the name of the event on that day.
My Current code
class datetime
{
string sTemp = DateTime.Now.ToString("yyyy-MM-dd");
TimeSpan m_Time = DateTime.Now - DateTime.Now;
DateTime m_EventStartTime = DateTime.Now;
m_Time = DateTime.Now - m_EventStartTime
}
I haven't figured out how to specify that I want 30 days, nor have I figured out how to get it to call correctly into the List box.
can anyone give me some help please?
Removed: You must either be really ambitious or completely off of your rocker.
Me: I've been off my rocker for years now
|
|
|
|
|
Hi,
Could you simply loop the desired amount of dates and add them to listview? For example:
for (int i = 0; i <= 30; i++) {
this.listView1.Items.Add(System.DateTime.Now.AddDays(i).ToString("yyyy-MM-dd"));
}
Mika
|
|
|
|
|
How do i implement shortcut keys in VC#. i.e, if somebody keys in Alt+A, a new form should open
Its not the will, its the wish which drives fortune!
|
|
|
|
|
Have a menu item (or similar) to open a new form and assign Alt+A to it.
(You can set the menu item to be invisible if you like.)
|
|
|
|
|
that's what i want to know...how to implement that "alt+a"
Its not the will, its the wish which drives fortune!
|
|
|
|
|
The VS designer's property list for some controls has an entry for Shortcut.
|
|
|
|
|
Hi,
I have a listbox at .aspx file.At page load(.cs),I add two listitem to it then I bind with data from database. I want to show different color for different items in that list.
Thanks in advance.
|
|
|
|
|
We have an ASP.NET forum
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
how can the application foresee the item you(or others) will add??? in order to process it.
You can use a if/else statement to set the color = red or Blue or pink when the value = Soccer or David or Navy, but what happens to other values that you don´t know now?!
If i insert to your lisbox a value = "44toilets&11pigs" what color would the application set? only a default i presume! what do you have in mind?
Goodluck
|
|
|
|
|
Good Day,
Is there a fast way to do Circular Shift (Rotate) in C#?
Given a byte, I would like to be able to Rotate it N times.
Thanks!
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.
|
|
|
|
|
I love this sort of stuff. Something I just hacked together:
static byte CircularBitwiseShiftLeft(byte value, int times)
{
for (int i = 0; i < times % 8; i++)
{
value = (byte)((value << 1) | (value >> 7));
}
return value;
}
static byte CircularBitwiseShiftRight(byte value, int times)
{
for (int i = 0; i < times % 8; i++)
{
value = (byte)((value >> 1) | ((value & 0x1) << 7));
}
return value;
}
/edit: added % 8 to eliminate duplicate rotations for times > 8
regards
modified on Thursday, July 24, 2008 1:32 PM
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanks,
For efficiency, can I put:
times%=16;
Since after 16 rotations, its just 0.
I mean, rot 17 is just rot 1.
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.
|
|
|
|
|
Good point, I'd rather do:
for (int i = 0; i < times % 8; i++)
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi,
if it is a byte, then it is modulo 8 you want.
IMO, assuming you need a lot of those, the fastest implementation for byte data is
using a two-dimensional array, properly initialized.
byteShifter[shiftAmount%8][value];
Of course you could store all kinds of 2-operand functions in such a table,
not just rotates.
For larger data items, this approach is becoming memory costly.
FYI: with C# modulo may yield negative values for negative inputs, you may have
to correct for that.
|
|
|
|
|
Ew, not loops.
public static byte
RightRotate
(
byte value
,
byte times
)
{
times %= 8 ;
return ( (byte) ( value >> times | value << 8-times ) ) ;
}
public static byte
LeftRotate
(
byte value
,
byte times
)
{
times %= 8 ;
return ( (byte) ( value << times | value >> 8-times ) ) ;
}
But as Luc says... table lookup.
|
|
|
|
|
PIEBALDconsult wrote: But as Luc says... table lookup.
Would that really be faster?
It looks to me like validating the indexes and calculating the offset in the array data would be about as much work as just calculating the value.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
|
I don't think << is circular but I do believe there is an opcode which is which would mean C++ and not C#
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|