public
Form1()
{
InitializeComponent();
RadDateTimePickerCalendar datePickerCalendarBehavior = (
this
.dtpTest.DateTimePickerElement.GetCurrentBehavior()
as
RadDateTimePickerCalendar);
RadCalendar calendar = datePickerCalendarBehavior.Calendar;
calendar.ShowFooter =
true
;
calendar.CalendarElement.CalendarStatusElement.Text =
""
;
datePickerCalendarBehavior.DropDownMinSize =
new
Size(250, 250);
dtpTest.NullableValue =
null
;
dtpTest.NullDate = System.Convert.ToDateTime(
"01/01/0001"
);
dtpTest.NullText =
" "
;
}
private
void
dtpTest_KeyDown(
object
sender, KeyEventArgs e)
{
if
(e.KeyData == Keys.Delete)
{
dtpTest.SetToNullValue();
e.Handled =
true
;
}
}
I am trying to use an Autocompletebox similar to a list view. I am doing this because of its compact form and look and feel. I am not using the Auto complete or suggestion options. I am using a separate dialog box to populate the control with data. I am also wanting use this control as an attachment manager. Something similar to the way outlook presents attachments.
Populating the control seems to be fairly easy. Although I would have expected a function to add to the internal collection rather than just an append method.
Here is how I am populating my AutoCompleteBox.
private void BuildCCList()
{
radCCList.Clear();
foreach(Contact curContact in m_objTicket.CCList)
{
radCCList.AppendText(curContact + ";");
}
}
This works pretty good; but, when I attempt to access those objects in the delete functions I have issues. I am not able to cast the item being deleted back to my Contact Class. It seems that the internal collection for the Autocompletebox is strings only. There seems to be a value field but I have not figured out how to set that.
((RadAutoCompleteBoxElement)this.radCCList.TextBoxElement).Items.CollectionChanged += Items_CollectionChanged;
private void Items_CollectionChanged(object sender, Telerik.WinControls.Data.NotifyCollectionChangedEventArgs e)
{
if (e.Action == NotifyCollectionChangedAction.Remove)
{
foreach(object objContact in e.NewItems)
{
Contact removeContact = (Contact)objContact;
m_objTicket.CCList.Remove(removeContact);
}
}
}
Is there any other way of populating the control that would allow me to add my custom objects to the internal list? Is there another control that I may be able to get a similar look and feel from? In the end I am looking for a compact list of objects that can be add to and deleted from with a minimal foot print on the form.
Any help would be appreciated.
public
partial
class
Form1 : Form
{
public
Form1()
{
InitializeComponent();
radGridView1.CustomFiltering += radGridView1_CustomFiltering;
}
private
void
Form1_Load(
object
sender, EventArgs e)
{
radGridView1.MasterTemplate.Columns.Clear();
GridViewTextBoxColumn v1Col =
new
GridViewTextBoxColumn(
"Value1"
);
v1Col.Name =
"Value1"
;
radGridView1.MasterTemplate.Columns.Add(v1Col);
GridViewTextBoxColumn v2Col =
new
GridViewTextBoxColumn(
"Value2"
);
v2Col.Name =
"Value2"
;
radGridView1.MasterTemplate.Columns.Add(v2Col);
radGridView1.MasterTemplate.EnableFiltering =
true
;
radGridView1.MasterTemplate.EnableCustomFiltering =
true
;
radGridView1.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
BindingList<Thing> stuff =
new
BindingList<Thing>();
stuff.Add(
new
Thing(
"One"
,
"Two"
));
stuff.Add(
new
Thing(
"Filter"
,
"Two"
));
stuff.Add(
new
Thing(
"Three"
,
"Four"
));
radGridView1.DataSource = stuff;
}
private
void
radGridView1_CustomFiltering(
object
sender, Telerik.WinControls.UI.GridViewCustomFilteringEventArgs e)
{
if
((e.Row.DataBoundItem
as
Thing).Value1 ==
"Filter"
)
{
e.Visible =
false
;
}
e.Handled = !e.Visible;
}
}
public
class
Thing
{
public
string
Value1 {
get
;
set
; }
public
string
Value2 {
get
;
set
; }
public
Thing(
string
val1,
string
val2)
{
Value1 = val1;
Value2 = val2;
}
}
Please help me on this.Very urgent