bootstrap fuelux datagrid表头怎么添加checkbox多选框

bootstrap fuelux datagrid表头怎么添加checkbox多选框,第1张

winform datagridview表头怎么增加复选框,点击表头的复选框,下面行的复选全选或全未选

2011-03-08 14:22

using System

using System.Collections.Generic

using System.ComponentModel

using System.Data

using System.Drawing

using System.Linq

using System.Text

using System.Windows.Forms

namespace WindowsFormsApplication1

{

publicpartialclass Form1 : Form

{

private DataGridView DataGridView1 =new DataGridView()

private CheckBox CheckBox1 =new CheckBox()

public Form1()

{

InitializeComponent()

}

privatevoid Form1_Load(object sender, EventArgs e)

{

CheckBox1.CheckedChanged += CheckBox1_CheckedChanged

DataGridView1.CellPainting += DataGridView1_CellPainting

this.DataGridView1.AllowUserToResizeRows =false

this.DataGridView1.AllowUserToResizeColumns =false

this.DataGridView1.Dock = DockStyle.Fill

this.DataGridView1.Columns.Add(new DataGridViewCheckBoxColumn())

this.DataGridView1.Columns.Add("Column2", "Column2")

for (int i =1i <=3i++)

{

this.DataGridView1.Rows.Add(0, "Row"+ i.ToString() +" Column2")

}

this.CheckBox1.Visible =false

this.CheckBox1.Text ="CheckBox"

this.Controls.Add(DataGridView1)

this.Controls.Add(CheckBox1)

}

privatevoid CheckBox1_CheckedChanged(object send, System.EventArgs e)

{

for (int i =0i <=this.DataGridView1.RowCount -1i++)

{

this.DataGridView1.Rows.SharedRow(i).SetValues(CheckBox1.Checked)

}

}

privatevoid DataGridView1_CellPainting(object sender, System.Windows.Forms.DataGridViewCellPaintingEventArgs e)

{

if (e.RowIndex ==-1&e.ColumnIndex ==0)

{

Point p =this.DataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true).Location

p.Offset(this.DataGridView1.Left, this.DataGridView1.Top)

this.CheckBox1.Location = p

this.CheckBox1.Size =this.DataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false).Size

this.CheckBox1.Visible =true

this.CheckBox1.BringToFront()

}

}

}

}

<!DOCTYPE html><html><head> <title>jQuery bootstrap-select可搜索多选下拉列表插件</title> <script src="../js/jquery-1.11.3.js"></script> <script type="text/javascript" src="../js/bootstrap-select.js"></script> <link rel="stylesheet" type="text/css" href="../css/bootstrap-select.css"/> <link href="../css/dist/css/bootstrap.css" rel="stylesheet"/> <script src="../css/dist/js/bootstrap.js"></script> <script type="text/javascript"> $(document).ready(function () {$('.selectpicker').selectpicker({'selectedText': 'cat',header: 'Select a condiment','noneSelectedText': '请选择','deselectAllText': '全不选','selectAllText': '全选'}) }) </script></head><body><select class="selectpicker" multiple data-live-search="true" data-actions-box="true"> <option>name</option> <option>addr</option> <option>email</option> <option selected>phone</option> <option>tel</option></select></body></html>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/bake/11439393.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-16
下一篇 2023-05-16

发表评论

登录后才能评论

评论列表(0条)

保存