|
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
|
|
|
|
|
True, << and >> means Left Shift and Right Shift.
But when done in a specific way, it can be "tricked" to do Circular shifts.
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.
|
|
|
|
|
Hi,
Problem:
I have a VS2005 C# Application that uses a third party managed dll which needs a second unmanaged dll.
I added the managed dll to my projects references, and so it is copied to my application path automatically after build. But what about the unmanaged dll?
How to copy it automatically? In C++/CLI you can set "copy local dependencies" and all dependencies are copied automatically.
But in c# I found nothing like that?
Any Ideas? Thanks for any help!
|
|
|
|
|
Don't know if there's an automatism for this in Visual Studio. I usually put the unmanaged dll into the project folder and copy it with the post-build event command line:
copy "$(ProjectDir)unmanaged.dll" "$(TargetDir)\unmanaged.dll"
|
|
|
|
|
that was also my first idea.
but I don't want to copy to the targetdir of the project, but to the output path of the whole solution ... since my project is used in other projects and solution dir's may vary.
so I tried something like that:
copy "$(ProjectDir)unmanaged.dll" "$(SolutionDir)\$(SolutionName)\unmanaged.dll"
Problem is, SolutionDir is not the OutputPath and there's no macro that defines the output path!?
Of course I can use "$(SolutionDir)\$(SolutionName)\$(OutDir) ... but this works only if Solution and the Project are build with same settings.
But why is there no macro for the Solution output path!?
By the way, the second proposal just works fine.
|
|
|
|
|
By the way, the second proposal just works fine.
Yes, I know. Just didn't think of it cause I always copy things to TargetDir. This is because we often use a kind of plug in technique: application reads from configuration from which dll to load the controls, so we don't have a reference to the controls dll and the application won't find it when started from VS, unless we copy it to the folder where the exe ist started.
|
|
|
|
|
AFAIK there should be a "Copy to Output Dir" property. Select the component in solution explorer and check the properties. There you can set
Build Action -> Component
Copy to output Dir -> Copy Always/Copy if newer
*jaans
|
|
|
|
|
Hi,
I have encountered a very strange problem.
I have a stuct that has a string variable inside.
I'm creating a list of the Struct's type, and try to assign the string variable.
this doesn't work !!!
but If I create a Class instead of a struct this work!!
The Struct:
public struct Struct1
{
private string s;
public Struct1(string d)
{
s = "";
}
public void SetS(string i) { s = i; }
public string GetS() { return s; }
}
The Class:
class myStr
{
private string s;
public myStr(){}
public void SetS(string i) { s = i; }
public string GetS() { return s; }
}
The Main:
static void Main(string[] args)
{
List<Struct1> ls = new List<Struct1>();
Struct1 str = new Struct1("f");
ls.Add(str);
ls[0].SetS("hi");
string mys = ls[0].GetS();
Console.WriteLine("mys: " + mys);
List<myStr> ls2 = new List<myStr>();
myStr str2 = new myStr();
ls2.Add(str2);
ls2[0].SetS("hello");
string mys2 = ls2[0].GetS();
Console.WriteLine("mys2: " + mys2);
}
The output is:
mys:
mys2: hello
this seems very strange!
I would be very happy if someone has an explanation.
Thanks.
|
|
|
|
|
lune12 wrote: this seems very strange!
No, the behaviour is perfectly correct.
lune12 wrote: I would be very happy if someone has an explanation.
Read up on the differences between value and reference types.
|
|
|
|