Hi,
I have a filledListBox:
private void fillmyListBox(DataTable dt)
{
this._myListBox.SelectedIndexChanged -= this._myListBox_SelectedIndexChanged;
_myListBox.DataSource = dt;
_myListBox.ValueMember = dt.Columns["ID"].ToString();
_myListBox.DisplayMember = dt.Columns["Name"].ToString();
this._myListBox.SelectedIndexChanged += this._myListBox_SelectedIndexChanged;
}
It is anOwnerDrawFixed so I add this:
void _myListBox_DrawItem(object sender, DrawItemEventArgs e)
{
e.DrawBackground();
TextFormatFlags flags = TextFormatFlags.SingleLine | TextFormatFlags.Right;
if (e.Index >= 0 && e.Index < _myListBox.Items.Count)
{
Color fore = _myListBox.ForeColor;
if ((e.State & DrawItemState.Selected) != 0)
fore = SystemColors.HighlightText;
DataRowView drv = (DataRowView)this._myListBox.Items[e.Index];
TextRenderer.DrawText(e.Graphics, drv.Row.ItemArray[1].ToString(), _myListBox.Font, e.Bounds, fore, flags);
}
}
private void _myListBox_MeasureItem(object sender, MeasureItemEventArgs e)
{
ListBox theListBox = (ListBox)sender;
string itemString = (string)theListBox.Items[e.Index];
e.ItemHeight = 18;
}
And now, the problem:
Each time I want to debug one of those functions - the debuger dosen't stop runing. The list itemsis filled over and over again.
Enother problem, and I assume it accures from same reason: in run-time - if the page length is longer then the screen height - pressing on one of the items in list - causes the scroller jump tothebottom of page.
(btw, It also happenswhen pressing on text in my RichTextBox, but I'm not sure its the same problem)
I would be very happy if someone can explain me the reason for all the above.