在 DevExpress GridView 上增加 RowHeight 的最佳方法?
Best way to increase RowHeight on a DevExpress GridView?
对不起,如果我的解释有误,我是新来的实习生。
我有一个使用 DevExpress 的 VB 前端的 Winforms 应用程序。
它有一个代表 DataTable 的 gridView。
GridView 中的这些列之一用于描述,我相信它是一个 repositoryItemMemoEdit
列,它用于显示从几行到整个段落的文本。
我发现设置 GridView.OptionsView.RowAutoHeight = True
可以让我的行完整显示文本,但有时文本太大。
我正在寻找使该行显示第一行或第二行并让其余文本通过鼠标悬停时出现的工具提示显示或显示更多和更少显示的最佳方法扩展和收缩行以适合文本或仅显示第一行的按钮。解决方案甚至可以将第一行设为超链接并打开一个新的弹出窗口 window 哈哈。
任何人都可以指出我正确的方向吗?我对 DevExpress 几乎一无所知,他们的大部分论坛答案只是没有可视化表示的代码块,所以我什至看不出它是否是我正在寻找的...
谢谢。
编辑:TLDR:让用户在 GridView 中随时查看更多文本的最佳方式是什么?
The solution could even be making the first line a hyperlink and make it open a new popup window.
订阅 GridView.RowCellClick
事件,订阅 GridView.ShowingEditor
事件并显示包含单元格内容的 XtraMessageBox
:
Imports DevExpress.XtraEditors
Imports DevExpress.XtraGrid.Views.Grid
Private Sub GridView1_RowCellClick(sender As Object, e As DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs) Handles GridView1.RowCellClick
If e.Column.Equals(GridView1.Columns("DesiredColumn")) Then
XtraMessageBox.Show(GridView1.GetFocusedDataRow()("DesiredColumn").ToString())
End If
End Sub
Private Sub GridView1_ShowingEditor(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles GridView1.ShowingEditor
If GridView1.FocusedColumn.Equals(GridView1.Columns("DesiredColumn")) Then
e.Cancel = True
End If
End Sub
点击的单元格:
也许最好的方法是处理 GridView.CustomDrawCell event and handle this manually in ToolTipController.GetActiveObjectInfo 事件。
private void GridView1_CustomDrawCell(object sender, RowCellCustomDrawEventArgs e)
{
if (e.Column.FieldName == "DesiredColumn")
{
// handle display logic here, this is just POC
var row = GridView1.GetDataRow(e.RowHandle);
var text = row["DesiredColumn"].ToString();
if (text.Length > 100) {
e.DisplayText = text.Substring(0, 100) + "...";
e.Handled = true;
}
}
}
private void toolTipController1_GetActiveObjectInfo(object sender, ToolTipControllerGetActiveObjectInfoEventArgs e)
{
ToolTipControlInfo info;
var gv = this.GridControl1.GetViewAt(e.ControlMousePosition) as GridView;
if (gv == null)
{
return;
}
var hInfo = gv.CalcHitInfo(e.ControlMousePosition);
if ((e.SelectedControl is GridControl))
{
if (hInfo.InRowCell)
{
if (hInfo.Column == gv.Columns["DesiredColumn"])
{
var row = gv.GetDataRow(hInfo.RowHandle);
var text = row["DesiredColumn"].ToString;
info = new ToolTipControlInfo(this.GridControl1, text);
e.Info = info;
}
}
}
}
对不起,如果我的解释有误,我是新来的实习生。
我有一个使用 DevExpress 的 VB 前端的 Winforms 应用程序。
它有一个代表 DataTable 的 gridView。
GridView 中的这些列之一用于描述,我相信它是一个 repositoryItemMemoEdit
列,它用于显示从几行到整个段落的文本。
我发现设置 GridView.OptionsView.RowAutoHeight = True
可以让我的行完整显示文本,但有时文本太大。
我正在寻找使该行显示第一行或第二行并让其余文本通过鼠标悬停时出现的工具提示显示或显示更多和更少显示的最佳方法扩展和收缩行以适合文本或仅显示第一行的按钮。解决方案甚至可以将第一行设为超链接并打开一个新的弹出窗口 window 哈哈。
任何人都可以指出我正确的方向吗?我对 DevExpress 几乎一无所知,他们的大部分论坛答案只是没有可视化表示的代码块,所以我什至看不出它是否是我正在寻找的...
谢谢。
编辑:TLDR:让用户在 GridView 中随时查看更多文本的最佳方式是什么?
The solution could even be making the first line a hyperlink and make it open a new popup window.
订阅 GridView.RowCellClick
事件,订阅 GridView.ShowingEditor
事件并显示包含单元格内容的 XtraMessageBox
:
Imports DevExpress.XtraEditors
Imports DevExpress.XtraGrid.Views.Grid
Private Sub GridView1_RowCellClick(sender As Object, e As DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs) Handles GridView1.RowCellClick
If e.Column.Equals(GridView1.Columns("DesiredColumn")) Then
XtraMessageBox.Show(GridView1.GetFocusedDataRow()("DesiredColumn").ToString())
End If
End Sub
Private Sub GridView1_ShowingEditor(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles GridView1.ShowingEditor
If GridView1.FocusedColumn.Equals(GridView1.Columns("DesiredColumn")) Then
e.Cancel = True
End If
End Sub
点击的单元格:
也许最好的方法是处理 GridView.CustomDrawCell event and handle this manually in ToolTipController.GetActiveObjectInfo 事件。
private void GridView1_CustomDrawCell(object sender, RowCellCustomDrawEventArgs e)
{
if (e.Column.FieldName == "DesiredColumn")
{
// handle display logic here, this is just POC
var row = GridView1.GetDataRow(e.RowHandle);
var text = row["DesiredColumn"].ToString();
if (text.Length > 100) {
e.DisplayText = text.Substring(0, 100) + "...";
e.Handled = true;
}
}
}
private void toolTipController1_GetActiveObjectInfo(object sender, ToolTipControllerGetActiveObjectInfoEventArgs e)
{
ToolTipControlInfo info;
var gv = this.GridControl1.GetViewAt(e.ControlMousePosition) as GridView;
if (gv == null)
{
return;
}
var hInfo = gv.CalcHitInfo(e.ControlMousePosition);
if ((e.SelectedControl is GridControl))
{
if (hInfo.InRowCell)
{
if (hInfo.Column == gv.Columns["DesiredColumn"])
{
var row = gv.GetDataRow(hInfo.RowHandle);
var text = row["DesiredColumn"].ToString;
info = new ToolTipControlInfo(this.GridControl1, text);
e.Info = info;
}
}
}
}