sorted lists are normally sorted by key not value in ascending order. this is how to create a sorted list by value in descending order
class DescendingComparer : IComparer
{
public int Compare(object x, object y)
{
try
{
return System.Convert.ToInt32(x).CompareTo(System.Convert.ToInt32(y)) * -1;
}
catch (Exception ex)
{
return x.ToString().CompareTo(y.ToString());
}
}
}
class KeySortedList : SortedList
{
public SortedList ReversedList = new SortedList(new DescendingComparer());
public new void Add(object key, object value)
{
ReversedList.Add(value, key);
base.Add(key, value);
}
}
Wednesday, August 13, 2008
Thursday, August 07, 2008
Undefined function 'CONVERT' in expression issue in Office 12
you might get a "Undefined function 'CONVERT' in expression" in Crystal Reports if you are using Office 12 Access DB, to correct this you have to convert the left hand function,
eg,
Undefined function 'CONVERT' in expression "Crystal Reports"
CDATE({ERYTHROCYTE_SEDIMENTATION_RATE_HEADER.COLLECT_DATE}) >= cdate (2008, 07, 05)
to fix the problem, good luck
eg,
Undefined function 'CONVERT' in expression "Crystal Reports"
CDATE({ERYTHROCYTE_SEDIMENTATION_RATE_HEADER.COLLECT_DATE}) >= cdate (2008, 07, 05)
to fix the problem, good luck
Monday, August 04, 2008
snapshot C# using PaintEventArgs
In RichFocus we had a problem to get the control image. We used old print screen methods to do this before, and it captures the whole thing with the windows on top of the control ... so I decided to use the OnPaint method to re-draw it for us.
// Inside snapshot control ...
Rectangle rect = this.ClientRectangle;
//create an empty image with the same size of the control
Bitmap bmp = new Bitmap(rect.Width, rect.Height);
Graphics g = Graphics.FromImage(bmp);
PaintEventArgs p= new PaintEventArgs(g, rect);
// paint the background,
this.InvokePaintBackground(this, p);
// this will invoke the control paint method
this.InvokePaint(this, p);
// Inside snapshot control ...
Rectangle rect = this.ClientRectangle;
//create an empty image with the same size of the control
Bitmap bmp = new Bitmap(rect.Width, rect.Height);
Graphics g = Graphics.FromImage(bmp);
PaintEventArgs p= new PaintEventArgs(g, rect);
// paint the background,
this.InvokePaintBackground(this, p);
// this will invoke the control paint method
this.InvokePaint(this, p);
Subscribe to:
Posts (Atom)