Hi.
I have a "little" problem with the ListControl.
I am trying to do a little Chat thingy.. and facing a Problem when the items are formated with Styles (Font, Size, Bold...).
In my Test Application you will see some controls.
1.) ListControl that stores the written messages
2.) A TextBox to input the desired Text message
3.) 2 Buttons with the text 1 and 20 - The 20 Button just calls the 1 button 20 times
The 1 Button, inserts 3 Items into the ListControl
1st a HeaderItem with the UserName and the DateTime
2nd a TextItem with the given Text
3rd a FooterItem to get a space between Messages
4.) An indicator for the Items.Count Value of the ListControl
So now the Problems i have after i have added some Messages to the ListControl and do some scrolling at some Point you will notice 3 Errors.
1.) The last Item doesnt get selected (not Highlighted with the Orange Color)
2.) The scrolling doesnt work. The Scrollelement moves but the ListControl seems like frozen.
3.) No new Items get displayed, tough it works - Item Counter goes still up.
Another Problem is that when i call the 20 Buttons at first after the form loads, the last item doesnt get selected. But this isnt really an issue that i am facing in reall application, because this button only exists in this test application so that you can add items faster, since you need some. (Second time hitting this button selects list item fine, only doesnt work when hitting it at first)
Hope you guys can help me fix those problems, already tried some LayoutUpdates but no luck till now. :(
And a side Note Question, is there a way to change the HighLight MouseOver and the Select Color?
Source Code for test Application:
Designer:
I have a "little" problem with the ListControl.
I am trying to do a little Chat thingy.. and facing a Problem when the items are formated with Styles (Font, Size, Bold...).
In my Test Application you will see some controls.
1.) ListControl that stores the written messages
2.) A TextBox to input the desired Text message
3.) 2 Buttons with the text 1 and 20 - The 20 Button just calls the 1 button 20 times
The 1 Button, inserts 3 Items into the ListControl
1st a HeaderItem with the UserName and the DateTime
2nd a TextItem with the given Text
3rd a FooterItem to get a space between Messages
4.) An indicator for the Items.Count Value of the ListControl
So now the Problems i have after i have added some Messages to the ListControl and do some scrolling at some Point you will notice 3 Errors.
1.) The last Item doesnt get selected (not Highlighted with the Orange Color)
2.) The scrolling doesnt work. The Scrollelement moves but the ListControl seems like frozen.
3.) No new Items get displayed, tough it works - Item Counter goes still up.
Another Problem is that when i call the 20 Buttons at first after the form loads, the last item doesnt get selected. But this isnt really an issue that i am facing in reall application, because this button only exists in this test application so that you can add items faster, since you need some. (Second time hitting this button selects list item fine, only doesnt work when hitting it at first)
Hope you guys can help me fix those problems, already tried some LayoutUpdates but no luck till now. :(
And a side Note Question, is there a way to change the HighLight MouseOver and the Select Color?
Source Code for test Application:
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Text;
using
System.Windows.Forms;
using
Telerik.WinControls;
using
Telerik.WinControls.UI;
public
partial
class
RadForm1 : RadForm
{
public
RadForm1()
{
InitializeComponent();
radTextBox1.Text =
"Some random Text!"
;
radListControl1.AutoSizeItems =
true
;
radTextBox1.Font =
new
Font(
"Times New Roman"
, 10, FontStyle.Bold);
radTextBox1.TextBoxElement.ForeColor = Color.Red;
radListControl1.SelectionMode = SelectionMode.One;
}
List<
int
> ids =
new
List<
int
>();
private
int
GetNewId()
{
int
returnValue = 0;
do
{
returnValue =
new
Random().Next(
int
.MaxValue);
}
while
(ids.IndexOf(returnValue) >= 0);
ids.Add(returnValue);
return
returnValue;
}
private
void
radButton1_Click(
object
sender, EventArgs e)
{
RadListDataItem itemHeader =
new
RadListDataItem(
string
.Format(
"<html><b>{0}</b> ({1})</html>"
,
"Some User"
, DateTime.Now), GetNewId());
radListControl1.Items.Add(itemHeader);
RadListDataItem itemText =
new
RadListDataItem(radTextBox1.Text, GetNewId());
itemText.TextWrap =
true
;
itemText.Font = radTextBox1.Font;
itemText.ForeColor = radTextBox1.TextBoxElement.ForeColor;
radListControl1.Items.Add(itemText);
RadListDataItem itemFooter =
new
RadListDataItem(
" "
, GetNewId());
radListControl1.Items.Add(itemFooter);
radListControl1.SelectedItem = itemFooter;
radTextBox2.Text = radListControl1.Items.Count.ToString();
}
private
void
radButton2_Click(
object
sender, EventArgs e)
{
for
(
int
i = 0; i < 20; i++)
{
radButton1_Click(
null
,
null
);
}
}
}
Designer:
partial
class
RadForm1
{
/// <summary>
/// Required designer variable.
/// </summary>
private
System.ComponentModel.IContainer components =
null
;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected
override
void
Dispose(
bool
disposing)
{
if
(disposing && (components !=
null
))
{
components.Dispose();
}
base
.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private
void
InitializeComponent()
{
this
.radListControl1 =
new
Telerik.WinControls.UI.RadListControl();
this
.radTextBox1 =
new
Telerik.WinControls.UI.RadTextBox();
this
.radButton1 =
new
Telerik.WinControls.UI.RadButton();
this
.radButton2 =
new
Telerik.WinControls.UI.RadButton();
this
.radTextBox2 =
new
Telerik.WinControls.UI.RadTextBox();
this
.label1 =
new
System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(
this
.radListControl1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(
this
.radTextBox1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(
this
.radButton1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(
this
.radButton2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(
this
.radTextBox2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(
this
)).BeginInit();
this
.SuspendLayout();
//
// radListControl1
//
this
.radListControl1.CaseSensitiveSort =
true
;
this
.radListControl1.ItemHeight = 18;
this
.radListControl1.Location =
new
System.Drawing.Point(12, 12);
this
.radListControl1.Name =
"radListControl1"
;
this
.radListControl1.Size =
new
System.Drawing.Size(274, 229);
this
.radListControl1.TabIndex = 0;
this
.radListControl1.Text =
"radListControl1"
;
//
// radTextBox1
//
this
.radTextBox1.Location =
new
System.Drawing.Point(12, 247);
this
.radTextBox1.Name =
"radTextBox1"
;
this
.radTextBox1.Size =
new
System.Drawing.Size(192, 20);
this
.radTextBox1.TabIndex = 1;
this
.radTextBox1.TabStop =
false
;
this
.radTextBox1.Text =
"radTextBox1"
;
//
// radButton1
//
this
.radButton1.Location =
new
System.Drawing.Point(211, 247);
this
.radButton1.Name =
"radButton1"
;
this
.radButton1.Size =
new
System.Drawing.Size(33, 24);
this
.radButton1.TabIndex = 2;
this
.radButton1.Text =
"1"
;
this
.radButton1.Click +=
new
System.EventHandler(
this
.radButton1_Click);
//
// radButton2
//
this
.radButton2.Location =
new
System.Drawing.Point(250, 247);
this
.radButton2.Name =
"radButton2"
;
this
.radButton2.Size =
new
System.Drawing.Size(36, 24);
this
.radButton2.TabIndex = 3;
this
.radButton2.Text =
"20"
;
this
.radButton2.Click +=
new
System.EventHandler(
this
.radButton2_Click);
//
// radTextBox2
//
this
.radTextBox2.Location =
new
System.Drawing.Point(211, 277);
this
.radTextBox2.Name =
"radTextBox2"
;
this
.radTextBox2.Size =
new
System.Drawing.Size(75, 20);
this
.radTextBox2.TabIndex = 4;
this
.radTextBox2.TabStop =
false
;
//
// label1
//
this
.label1.AutoSize =
true
;
this
.label1.Location =
new
System.Drawing.Point(153, 277);
this
.label1.Name =
"label1"
;
this
.label1.Size =
new
System.Drawing.Size(52, 13);
this
.label1.TabIndex = 5;
this
.label1.Text =
"Counter:"
;
//
// RadForm1
//
this
.AutoScaleDimensions =
new
System.Drawing.SizeF(6F, 13F);
this
.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this
.ClientSize =
new
System.Drawing.Size(298, 303);
this
.Controls.Add(
this
.label1);
this
.Controls.Add(
this
.radTextBox2);
this
.Controls.Add(
this
.radButton2);
this
.Controls.Add(
this
.radButton1);
this
.Controls.Add(
this
.radTextBox1);
this
.Controls.Add(
this
.radListControl1);
this
.Name =
"RadForm1"
;
//
//
//
this
.RootElement.ApplyShapeToControl =
true
;
this
.Text =
"RadForm1"
;
this
.ThemeName =
"ControlDefault"
;
((System.ComponentModel.ISupportInitialize)(
this
.radListControl1)).EndInit();
((System.ComponentModel.ISupportInitialize)(
this
.radTextBox1)).EndInit();
((System.ComponentModel.ISupportInitialize)(
this
.radButton1)).EndInit();
((System.ComponentModel.ISupportInitialize)(
this
.radButton2)).EndInit();
((System.ComponentModel.ISupportInitialize)(
this
.radTextBox2)).EndInit();
((System.ComponentModel.ISupportInitialize)(
this
)).EndInit();
this
.ResumeLayout(
false
);
this
.PerformLayout();
}
#endregion
private
Telerik.WinControls.UI.RadListControl radListControl1;
private
Telerik.WinControls.UI.RadTextBox radTextBox1;
private
Telerik.WinControls.UI.RadButton radButton1;
private
Telerik.WinControls.UI.RadButton radButton2;
private
Telerik.WinControls.UI.RadTextBox radTextBox2;
private
System.Windows.Forms.Label label1;
}