最后一个列标题后的DataGridView空白 [英] DataGridView White Space After Last Column Header

查看:177
本文介绍了最后一个列标题后的DataGridView空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图模仿每个其他表格视图对DataGridView控件的作用,但我似乎无法得到正确的标题。



我想要一个所有标题右侧的空白标题,不移动,并且实际上不是标题。有没有一种方法可以在顶部绘制默认标题?

基本上,这是我的问题:

解决方案

试试这个

  Dim dt As New DataTable()
dt.Columns.Add(a)
dt.Columns.Add(b)
dt.Rows.Add(dt.NewRow())
dt.Rows.Add(dt.NewRow())
dt.Rows .Add(dt.NewRow())
dt.Rows.Add(dt.NewRow())
dt.Rows.Add(dt.NewRow())
dt.Rows.Add (dt.NewRow())
dt.Columns.Add()
dt.AcceptChanges()
DataGridView1.DataSource = dt
DataGridView1.AutoSize = True
DataGridView1.Columns(2).AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
DataGridView1.Columns(2).Resizable = DataGridViewTriState.False


I'm trying to mimic what every other tabular view does with the DataGridView control, but I can't seem to get the headers correct.

I want a blank header to the right of all headers, that does not move, and is not actually a header. Is there a way to paint the default header along the top?

Basically, this is my problem:

解决方案

Try this

Dim dt As New DataTable()
dt.Columns.Add("a")
dt.Columns.Add("b")
dt.Rows.Add(dt.NewRow())
dt.Rows.Add(dt.NewRow())
dt.Rows.Add(dt.NewRow())
dt.Rows.Add(dt.NewRow())
dt.Rows.Add(dt.NewRow())
dt.Rows.Add(dt.NewRow())
dt.Columns.Add(" ")
dt.AcceptChanges()
DataGridView1.DataSource = dt
DataGridView1.AutoSize = True
DataGridView1.Columns(2).AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
DataGridView1.Columns(2).Resizable = DataGridViewTriState.False

这篇关于最后一个列标题后的DataGridView空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆