求一WinForm控件

assky124 2009-08-24 11:21:08
具体是类似于DataGridView,或者ListView,不过当鼠标点击一行或者移到某行是,该行展开,显示更多的内容。
...全文
339 35 打赏 收藏 转发到动态 举报
写回复
用AI写文章
35 条回复
切换为时间正序
请发表友善的回复…
发表回复
assky124 2009-08-26
  • 打赏
  • 举报
回复
现在不回复不能提前了?

郁闷
assky124 2009-08-26
  • 打赏
  • 举报
回复
贴上实现代码,大家随便看看,顺便帮我测试下!

/*
* Write By yty at 2009/8/24
* WeiKe (C) 2009
*/

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace KitchenMana.UInter
{
public partial class DataGridViewRowEx : DataGridView
{
private UserControl _ucDetails;
private int _iRowHeight;

public DataGridViewRowEx()
{
InitializeComponent();

this.ScrollBars = ScrollBars.Vertical;
this._iRowHeight = 30;

this.Font = new Font("黑体", 12.5f);
//
this.RowHeadersWidth = 25;
this.SelectionMode = DataGridViewSelectionMode.FullRowSelect;

}

[Browsable(true),
Category("扩展属性")]
public override Font Font
{
get
{
return base.Font;
}
set
{
base.Font = value;
}
}
[Category("扩展属性"),
Description("获取或设置细节显示控件")]
public UserControl DetailControl
{
get
{
return this._ucDetails;
}
set
{
if (value != null)
{
this._ucDetails = value;
if (this.Width > 32 + this.RowHeadersWidth)
{
this._ucDetails.Width = this.Width - 32 - this.RowHeadersWidth;
}
this._ucDetails.Visible = false;
this.Controls.Add(this._ucDetails);
}
}
}

[Category("扩展属性"),
Description("获取或设置默认行高")]
public int DefaultRowHeight
{
get
{
return this._iRowHeight;
}
set
{
if (value > 20)
{
this._iRowHeight = value;
}
}
}
protected void ReSetRowHeight()
{
for (int i = 0; i < this.RowCount; i++)
{
this.Rows[i].Height = this._iRowHeight;
}
}

private void TreatTheDetailControl()
{
if (this._ucDetails != null)
{
if (this.CurrentRow.Index >= 0)
{
//ReSetRowHeight();
if (this.CurrentRow.Index >= this.FirstDisplayedCell.RowIndex)
{
this.CurrentRow.Height = this._ucDetails.Height;
this._ucDetails.Top = this.ColumnHeadersHeight + this._iRowHeight * (
this.CurrentRow.Index - this.FirstDisplayedCell.RowIndex);
this._ucDetails.Left = this.RowHeadersWidth;
this._ucDetails.Show();
}
else
{
this._ucDetails.Hide();
}
}
}
}

protected override void OnCellClick(DataGridViewCellEventArgs e)
{
base.OnCellClick(e);
ReSetRowHeight();
TreatTheDetailControl();
}

protected override void OnScroll(ScrollEventArgs e)
{
base.OnScroll(e);
TreatTheDetailControl();
//ReSetRowHeight();
}
protected override void OnCurrentCellChanged(EventArgs e)
{
base.OnCurrentCellChanged(e);
ReSetRowHeight();
TreatTheDetailControl();
}
}
}
assky124 2009-08-25
  • 打赏
  • 举报
回复
Infragistics系列控件 怎么看皮肤控件加组合控件的混合体,用了2下就崩掉了!可能是盗版的原因吧!
assky124 2009-08-25
  • 打赏
  • 举报
回复
我不是只要界面的美化,还有功能的扩展的。
liffe 2009-08-25
  • 打赏
  • 举报
回复
帮顶了。。。
hrbwgs1111 2009-08-25
  • 打赏
  • 举报
回复
24K純帥 2009-08-25
  • 打赏
  • 举报
回复
nani好高级,俺进来学习
assky124 2009-08-25
  • 打赏
  • 举报
回复
通过DataGrid添加一个UserControl 的方式效果好像很不错,不过有滚动条时,定位就是个大问题,有什么解决方案没?
mythad 2009-08-24
  • 打赏
  • 举报
回复
dev express控件treelist
qqiuzaihui 2009-08-24
  • 打赏
  • 举报
回复
那就添加一个窗体, 专用于显示你需要的信息. 如何?

        private Form2 frm;
private void button1_Click(object sender, EventArgs e)
{
DataTable dt = GetData();
this.dataGridView1.DataSource = dt.DefaultView;
}

private DataTable GetData()
{
DataTable dtData = new DataTable();
using (SqlConnection thisConnection = new SqlConnection(
@"Data Source=HUI\SQLSERVER;Initial Catalog=Northwind;Integrated Security=True"))
{
using (SqlDataAdapter thisAdapter = new SqlDataAdapter(
"SELECT * FROM Customers", thisConnection))
{
thisAdapter.Fill(dtData);
}
thisConnection.Close();
}
return dtData;
}

private void Form1_Load(object sender, EventArgs e)
{
frm = new Form2();
frm.TopLevel = false;
frm.FormBorderStyle = FormBorderStyle.None;
this.dataGridView1.Controls.Add(frm);
frm.Hide();
}

private void dataGridView1_CurrentCellChanged(object sender, EventArgs e)
{
if (this.dataGridView1.CurrentCell==null)
return;

Rectangle rect = this.dataGridView1.GetCellDisplayRectangle(dataGridView1.CurrentCell.ColumnIndex + 1,
dataGridView1.CurrentCell.RowIndex + 1, false);

frm.Location = new Point(rect.Left - 50, rect.Top - 10);
frm.Size = new Size(200, 200);
frm.BackColor = Color.Yellow;
//此处可对frm进行初始化值
frm.Show();
}

private void dataGridView1_Leave(object sender, EventArgs e)
{
frm.Hide();
}


assky124 2009-08-24
  • 打赏
  • 举报
回复
TreeView 不怎么好,和我的需求差别太大了。

我要做的是,列表显示一般信息,展开后,显示图文并茂的效果
happyboyxq 2009-08-24
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 plqazokmwsx 的回复:]
我觉得你是不是可以用TreeView试下
[/Quote]
的确可以试一下,楼主的要求和这个差不多。
fengjian_428 2009-08-24
  • 打赏
  • 举报
回复
utral的控件好像可以
yinchuanshuxiu 2009-08-24
  • 打赏
  • 举报
回复
帮你顶,顺便打一个 c#交流群广告59714431
好_奇 2009-08-24
  • 打赏
  • 举报
回复
我觉得你是不是可以用TreeView试下
BitCoffee 2009-08-24
  • 打赏
  • 举报
回复
或者考虑当鼠标点击一行或者移到某行时,在鼠标的附近打开一个无边框的窗体.
surlew 2009-08-24
  • 打赏
  • 举报
回复
上网上面搜搜吧,好像见过类似效果的
LutzMark 2009-08-24
  • 打赏
  • 举报
回复
行点击事件里增加该行高度,或者嵌套ListBox之类
nixiang12 2009-08-24
  • 打赏
  • 举报
回复
dotnetbar
去弄弄
风之影子 2009-08-24
  • 打赏
  • 举报
回复
[Quote=引用 25 楼 bejon 的回复:]
请使用Infragistics系列控件,你所要的你所想到的,所没想到的该系列控件都能提供

网上也有破解版的,请自己找
[/Quote]\

如此之牛吗?
加载更多回复(14)

110,534

社区成员

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

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

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