I am having an issue with everything that has been said here. At first I could not get the item to be selected and/or highlighted. I got it working now with base.synchronizeproperties(); however, the behavior is unpredictable. When my mouse passes over an item it is highlighted as it should be by shadowing out the element but when I actually click on it (in which case it should turn gold) nothing happens. It looks as if it is selected for an almost undetectable split second but then is quickly unselected. At times it does work but once one item is selected nothing else can be selected for a while until the program crashes with due to a null in my selected index changed event.
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
Telerik.WinControls.UI;
using
Telerik.WinControls.Layouts;
using
System.Drawing;
using
Telerik.WinControls;
using
System.Windows.Forms;
namespace
Crime_Information_System
{
public
class
csCustomInboxItem : SimpleListViewVisualItem
{
private
LightVisualElement Sender;
private
LightVisualElement Subject;
private
LightVisualElement TimeStamp;
private
StackLayoutPanel stackLayout;
protected
override
void
CreateChildElements()
{
base
.CreateChildElements();
stackLayout =
new
StackLayoutPanel();
stackLayout.Orientation = Orientation.Vertical;
Sender =
new
LightVisualElement();
Sender.TextAlignment = ContentAlignment.TopLeft;
Sender.Margin =
new
Padding(1, 1, 1, 2);
Sender.Font =
new
System.Drawing.Font(
"Segoe UI"
, 10, FontStyle.Bold, GraphicsUnit.Point);
stackLayout.Children.Add(Sender);
TimeStamp =
new
LightVisualElement();
TimeStamp.TextAlignment = ContentAlignment.TopLeft;
TimeStamp.Margin =
new
Padding(2, 1, 1, 2);
TimeStamp.Font =
new
System.Drawing.Font(
"Segoe UI"
, 10, FontStyle.Regular, GraphicsUnit.Point);
TimeStamp.ForeColor = Color.Black;
stackLayout.Children.Add(TimeStamp);
Subject =
new
LightVisualElement();
Subject.TextAlignment = ContentAlignment.TopLeft;
Subject.Margin =
new
Padding(2, 3, 1, 1);
Subject.Font =
new
System.Drawing.Font(
"Segoe UI"
, 9, FontStyle.Regular, GraphicsUnit.Point);
Subject.ForeColor = Color.Blue;
stackLayout.Children.Add(Subject);
this
.Children.Add(stackLayout);
this
.Padding =
new
Padding(1, 2, 1, 2);
this
.Shape =
new
RoundRectShape(3);
this
.BorderColor = Color.Black;
this
.BorderGradientStyle = GradientStyles.Solid;
this
.DrawBorder =
true
;
this
.DrawFill =
true
;
this
.BackColor = Color.Azure;
this
.GradientStyle = GradientStyles.Solid;
//NotifyParentOnMouseInput = true;
//ShouldHandleMouseInput = false;
}
protected
override
void
SynchronizeProperties()
{
base
.SynchronizeProperties();
this
.Sender.Text = Convert.ToString(CentralDataStore.AllUsers.Find(p => p.intUserID ==
Convert.ToInt64(
this
.Data[
"SenderID"
])).strFirstName +
" "
+
CentralDataStore.AllUsers.Find(p => p.intUserID ==
Convert.ToInt64(
this
.Data[
"SenderID"
])).strLastName);
if
(Convert.ToDateTime(
this
.Data[
"Date"
]).Date == DateTime.Now.Date)
//uses time sent as opposed to a real date
{
this
.TimeStamp.Text = Convert.ToDateTime(
this
.Data[
"Date"
]).ToShortTimeString();
}
else
{
this
.TimeStamp.Text = Convert.ToDateTime(
this
.Data[
"Date"
]).ToShortDateString();
}
Subject.Text =
this
.Data[
"Subject"
].ToString();
if
(Convert.ToInt32(
this
.Data[
"Read"
]) == 1)
{
Sender.Font =
new
System.Drawing.Font(
"Segoe UI"
, 10, FontStyle.Italic, GraphicsUnit.Point);
Sender.ForeColor = Color.Gray;
TimeStamp.Font = TimeStamp.Font =
new
System.Drawing.Font(
"Segoe UI"
, 10, FontStyle.Italic, GraphicsUnit.Point);
TimeStamp.ForeColor = Color.Gray;
Subject.Font =
new
System.Drawing.Font(
"Segoe UI"
, 9, FontStyle.Italic, GraphicsUnit.Point);
Subject.ForeColor = Color.Gray;
}
else
{
Sender.Font =
new
System.Drawing.Font(
"Segoe UI"
, 10, FontStyle.Bold, GraphicsUnit.Point);
Sender.ForeColor = Color.Black;
TimeStamp.Font = TimeStamp.Font =
new
System.Drawing.Font(
"Segoe UI"
, 10, FontStyle.Regular, GraphicsUnit.Point);
TimeStamp.ForeColor = Color.Black;
Subject.Font =
new
System.Drawing.Font(
"Segoe UI"
, 9, FontStyle.Regular, GraphicsUnit.Point);
Subject.ForeColor = Color.Blue;
}
this
.Text =
""
;
//this is here to erase the system.Crime_Information_System.o_Email from
// the listitem shown.
}
protected
override
Type ThemeEffectiveType
{
get
{
return
typeof
(IconListViewVisualItem);
}
}
protected
override
SizeF MeasureOverride(SizeF availableSize)
{
SizeF measuredSize =
base
.MeasureOverride(availableSize);
this
.stackLayout.Measure(measuredSize);
return
measuredSize;
}
protected
override
SizeF ArrangeOverride(SizeF finalSize)
{
base
.ArrangeOverride(finalSize);
this
.stackLayout.Arrange(
new
RectangleF(PointF.Empty, finalSize));
return
finalSize;
}
}
}
//and this is the event code I am running on my form that should pop up a message box with the data that I am looking for.
private
void
radListView2_SelectedIndexChanged(
object
sender, EventArgs e)
{
oEmail Sender =
this
.radListView2.Items[radListView2.SelectedIndex].DataBoundItem
as
oEmail;
MessageBox.Show(Sender.Body);
}