Dotnetbar中的一个问题?

t6786780 2010-11-15 05:57:51
最近在研究Dotnetbar,可是有一个问题让人很郁闷。
直接拖拽一个DataGridViewX到窗体中,禁用DataGridViewX自带的 添加,删除,修改功能,后台写入下以下代码:
在最后一行中ButtonX的值总是不能显示,如果把
DataGridViewButtonXColumn column3 = new DataGridViewButtonXColumn(); 替换成
DataGridViewButtonColumn column3 = new DataGridViewButtonColumn(); 就能显示。我真郁闷的要死。有谁用过这个,帮下忙了。我现在的目的是不要 添加,删除,修改的功能,只需要让这个DataGridViewX展示数据就够了。让他把最后一行的那个ButtonX的值显示上去!谢谢了。

/// <summary>
/// 初始化实时DataGridViewX
/// </summary>
public void LoadFmMainRealTime(DataGridViewX dLvRealTime)
{
//
// 初始化列
//
DataGridViewTextBoxColumn column1 = new DataGridViewTextBoxColumn();
DataGridViewTextBoxColumn column2 = new DataGridViewTextBoxColumn();
DataGridViewButtonXColumn column3 = new DataGridViewButtonXColumn();
DataGridViewTextBoxColumn column4 = new DataGridViewTextBoxColumn();
column1.Width = 100;
column1.DataPropertyName = "bh";
column1.HeaderText = "编号";
column2.Width = 150;
column2.DataPropertyName = "zxshk";
column2.HeaderText = "执行时刻";
column3.Width = 250;
column3.HeaderText = "描述";
column3.DataPropertyName = "msh";
column4.Width = 524;
column4.Name = "info";
column4.DataPropertyName = "xx";
column4.HeaderText = "信息";
dLvRealTime.Columns.AddRange(new DataGridViewColumn[] { column1, column2, column3, column4 });
Rectangle ScreenArea = System.Windows.Forms.Screen.GetWorkingArea(dLvRealTime);
dLvRealTime.Columns["info"].Width = ScreenArea.Width - 570;
//
// 初始化数据
//
table = new DataTable("DemoTable");
table.Columns.Add(new DataColumn("bh") { DataType = System.Type.GetType("System.Int32") });
table.Columns.Add(new DataColumn("zxshk"));
table.Columns.Add(new DataColumn("msh"));
table.Columns.Add(new DataColumn("xx"));
for (int i = 0; i < 11; i++)
{
row = table.NewRow();
row[0] = i + 1;
row[1] = DateTime.Now.AddDays(i).ToString("yyy-MM-dd hh:mm:ss.fff");
if (i % 2 != 0)
row[2] = "莱昂纳多进入";
else if (i % 2 == 0)
row[2] = "莱昂纳多出去";
row[3] = "刷卡验证";
table.Rows.Add(row);
}
dataSet.Tables.Add(table);
bindingSource.DataMember = "DemoTable";

DataGridViewButtonXColumn bcx = dLvRealTime.Columns[2] as DataGridViewButtonXColumn;
if (bcx != null)
{
bcx.UseColumnTextForButtonValue = false;
bcx.BeforeCellPaint += Demo_BeforeCellPaint;
}
}

private void Demo_BeforeCellPaint(object sender, BeforeCellPaintEventArgs e)
{
DataGridViewButtonXColumn bcx = sender as DataGridViewButtonXColumn;
if (bcx != null)
{
if (bcx.Text == "莱昂纳多进入")
bcx.Image = new Bitmap(Application.StartupPath + @"\Images\arrow_down.gif");
else if (bcx.Text == "莱昂纳多出去")
bcx.Image = new Bitmap(Application.StartupPath + @"\Images\arrow_up.gif");
}
}
...全文
426 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
wenbowebo 2011-05-11
  • 打赏
  • 举报
回复
,建议使用DNB的AdvTree
lackyking 2010-12-01
  • 打赏
  • 举报
回复
private void Demo_BeforeCellPaint(object sender, BeforeCellPaintEventArgs e)
{
DataGridViewButtonXColumn bcx = sender as DataGridViewButtonXColumn;
if (bcx != null)
{
if (bcx.Text.Contains("莱昂纳多进入"))
bcx.Image = new Bitmap(Application.StartupPath + @"\Images\arrow_down.gif");
else if (bcx.Text.Contains("莱昂纳多出去"))
bcx.Image = new Bitmap(Application.StartupPath + @"\Images\arrow_up.gif");
}
}
t6786780 2010-11-17
  • 打赏
  • 举报
回复
算了,结贴吧
bloodish 2010-11-16
  • 打赏
  • 举报
回复
DNB中没有DataGridViewButtonXColumn这样的列类型,是楼主自己新增的?
如果是,那么是你自己实现的问题.

如果你不是大量数据需要显示,建议使用DNB的AdvTree,这个控件的扩展性更好,更容易自定义.
t6786780 2010-11-16
  • 打赏
  • 举报
回复
不至于吧,连个回复的都没有。
jsjhj2008 2010-11-16
  • 打赏
  • 举报
回复

110,529

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧