如何绘制表格winform c# [英] how to draw a table winform c#

查看:432
本文介绍了如何绘制表格winform c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我需要绘制一个包含内容的表格;

我尝试使用datagridview来做它,它工作正常但是我需要背景透明度。

还有其他办法吗?



 DataGridViewColumn dgc =  new  DataGridViewColumn(); 
for int k = 0 ; k < 2 ; k ++)
{
dgc = < span class =code-keyword> new DataGridViewTextBoxColumn();
dgc.HeaderText = 你好;
dgc.Name = 1;
dataGridView1.Columns.Add(dgc);
}
dataGridView1.Rows.Add( 1 1 );
dataGridView1.Rows.Add( 1 1 );

int i = 0 ;
int j = 0 ;
foreach (DataGridViewColumn c in dataGridView1.Columns)
{
if (i == 0
{
foreach (DataGridViewRow c1 in dataGridView1.Rows)
{
j + = c1.Height;
}
}
i + = c.Width;
}
dataGridView1.Width = i + 1 ;
dataGridView1.Height = j +1;







提前致谢。

解决方案

检查..

http://stackoverflow.com/questions/10809154/how-to-create-tables-in-windows-form-application [ ^ ]

http://stackoverflow.com/questions/14839635/draw-a-custom- table-in-windows-forms [ ^ ]

http://msdn.microsoft.com/en-us/library/aa984314%28v=vs.71%29.aspx [ ^ ]

http://stackoverflow.com/questions/15231456/is-it-possible-to-use-a-table-in-windows-forms-as-a-matrix [ ^ ]

Hello ,

I need to draw a table with content;
I have try to use datagridview to do it, it work but i need the background transparency.
is there any else way to do it ?

DataGridViewColumn dgc = new DataGridViewColumn();
              for (int k = 0; k < 2; k++)
              {
                  dgc = new DataGridViewTextBoxColumn();
                  dgc.HeaderText = "Hi there";
                  dgc.Name = "1";
                  dataGridView1.Columns.Add(dgc);
              }
              dataGridView1.Rows.Add(1, 1);
              dataGridView1.Rows.Add(1, 1);

              int i = 0;
              int j = 0;
              foreach (DataGridViewColumn c in dataGridView1.Columns)
              {
                  if (i == 0)
                  {
                      foreach (DataGridViewRow c1 in dataGridView1.Rows)
                      {
                          j += c1.Height;
                      }
                  }
                  i += c.Width;
              }
              dataGridView1.Width = i + 1;
              dataGridView1.Height =j +1;




Thanks in advance.

解决方案

Check..
http://stackoverflow.com/questions/10809154/how-to-create-tables-in-windows-form-application[^]
http://stackoverflow.com/questions/14839635/draw-a-custom-table-in-windows-forms[^]
http://msdn.microsoft.com/en-us/library/aa984314%28v=vs.71%29.aspx[^]
http://stackoverflow.com/questions/15231456/is-it-possible-to-use-a-table-in-windows-forms-as-a-matrix[^]


这篇关于如何绘制表格winform c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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