在combobox的下拉列表里显示的数据 就如同在datagrid 显示一样 数据显示在网络格里。
下面是我写的代码 它把代码分行,列的显示。
但无法显示出 数据周围的 线。
请问 如何实现?
谢谢!protected override void OnDrawItem(DrawItemEventArgs e)
{
e.DrawBackground();
if (0 <= e.Index)
{
e.Graphics.DrawString(this.m_table.Rows[e.Index][0].ToString(), e.Font, new SolidBrush(e.ForeColor), (float)e.Bounds.X, (float)e.Bounds.Y);
if (1 < this.m_table.Columns.Count)
{
int x = (base.DropDownWidth - base.Width) / (this.m_table.Columns.Count - 1);
if (this.m_table.Columns.Count <= columnLimit)
{
for (int i = 1; i < this.m_table.Columns.Count; i++)
{
e.Graphics.DrawString(this.m_table.Rows[e.Index][i].ToString(), e.Font, new SolidBrush(e.ForeColor), (float)(base.Width + (x * (i - 1))), (float)e.Bounds.Y);
}
}
else if (columnLimit < this.m_table.Columns.Count )
{
for (int i = 1; i < columnLimit; i++)
{
e.Graphics.DrawString(this.m_table.Rows[e.Index][i].ToString(), e.Font, new SolidBrush(e.ForeColor), (float)(base.Width + (x * (i - 1))), (float)e.Bounds.Y);
}
}
}
} #region //TODO #endregion e.DrawFocusRectangle();
}
下面是我写的代码 它把代码分行,列的显示。
但无法显示出 数据周围的 线。
请问 如何实现?
谢谢!protected override void OnDrawItem(DrawItemEventArgs e)
{
e.DrawBackground();
if (0 <= e.Index)
{
e.Graphics.DrawString(this.m_table.Rows[e.Index][0].ToString(), e.Font, new SolidBrush(e.ForeColor), (float)e.Bounds.X, (float)e.Bounds.Y);
if (1 < this.m_table.Columns.Count)
{
int x = (base.DropDownWidth - base.Width) / (this.m_table.Columns.Count - 1);
if (this.m_table.Columns.Count <= columnLimit)
{
for (int i = 1; i < this.m_table.Columns.Count; i++)
{
e.Graphics.DrawString(this.m_table.Rows[e.Index][i].ToString(), e.Font, new SolidBrush(e.ForeColor), (float)(base.Width + (x * (i - 1))), (float)e.Bounds.Y);
}
}
else if (columnLimit < this.m_table.Columns.Count )
{
for (int i = 1; i < columnLimit; i++)
{
e.Graphics.DrawString(this.m_table.Rows[e.Index][i].ToString(), e.Font, new SolidBrush(e.ForeColor), (float)(base.Width + (x * (i - 1))), (float)e.Bounds.Y);
}
}
}
} #region //TODO #endregion e.DrawFocusRectangle();
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货