我在C#窗口应用程序中使用了一个gridview。其中一个单元格有一长串文本(见下文),但每当它绑定到网格时,单元格将被裁剪,滚动条将显示全文。用鼠标拖动时滚动条也不能平滑滚动。在单元格C#gridview窗口中获取裁剪文本
我尝试了RowSize
和ColumnSize`模式的不同组合,但没有运气。
void FillGrid()
{
DataTable tasktable = new DataTable();
tasktable.Columns.Add("Logged By", typeof(string));
tasktable.Columns.Add("Date", typeof(DateTime));
tasktable.Columns.Add("Notes", typeof(string));
DataRow dr1;
//for (int i = 0; i < 100; i++)
//{
dr1 = tasktable.NewRow();
dr1[0] = "Sunit Shah";
dr1[1] = System.DateTime.Now;
dr1[2] = "Test Note";
tasktable.Rows.Add(dr1);
//}
dr1 = tasktable.NewRow();
dr1[0] = "Sunit Shah";
dr1[1] = System.DateTime.Now;
dr1[2] = "Test Note";
dr1[2] = "Paul Pogba will have a medical at Manchester United on Monday after
Juventus granted permission for him to seal a potential world record
transfer.Juventus manager Massimo Allegri refused to be drawn further
on the transfer when he was asked about it in his post-match press
conference following a friendly against West Ham at the London Stadium,
but an official at the Italian club confirmed they had authorised the
midfielder to have United doctors assess him ahead of the move.
Allegri merely said: ‘I spoke about Pogba the day before, we have
just finished a match and I don’t know much more, we will see on Monday
if he is a still Juventus player.’";
tasktable.Rows.Add(dr1);
DataTable fillNotesGrid = new DataTable();
fillNotesGrid = (from row in tasktable.AsEnumerable()
orderby row.Field<DateTime>("Date") descending
select row).CopyToDataTable();
dgvSIDetailsNotes.DataSource = fillNotesGrid;
}
你能发布你用来显示网格的代码吗? – Interminable
我刚刚添加了 – Hemil
我会考虑你为什么会在gridview中显示上述文本。在自己的文本框中显示在网格之外可能会更好,当您选择不同的行时,该框会发生变化。 – Takarii