-- 作者:cnsjroom
-- 发布时间:2022/2/25 9:48:00
-- 回复:(有点蓝)http://www.foxtable.com/webhelp/to...
老师看了帮助 参照做成如下:
显示按钮代码:
Dim ckl As WinForm.CheckedListBox = e.Form.Controls("CheckedListBox1") Dim tb As WinForm.Table = Forms("组合筛选").Controls("Table1") Dim nms As New List(of String) For i As Integer = 0 To ckl.Items.count - 1 \'获取已经勾选的列 If ckl.GetItemChecked(i) Then nms.Add(ckl.Items(i)) End If Next If nms.Count = 0 Then MessageBox.Show("至少要选择一列","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) Return End If For i As Integer = 0 To nms.count -1 For Each nm As String In nms tb.Table.Cols(nm).Visible = True tb.Table.Cols(nm).PrintWidth=80 Next Next
Dim bbt As WinForm.Button = Forms("组合筛选").Controls("Button1") bbt.PerformClick
实现效果: 【为什么列宽会变化与其他不协调?】
此主题相关图片如下:22.png
隐藏按钮代码:
Dim ckl As WinForm.CheckedListBox = e.Form.Controls("CheckedListBox1") Dim tb As WinForm.Table = Forms("组合筛选").Controls("Table1") Dim nms As New List(of String) For i As Integer = 0 To ckl.Items.count - 1 \'获取已经勾选的列 If ckl.GetItemChecked(i) Then nms.Add(ckl.Items(i)) End If Next If nms.Count = 0 Then MessageBox.Show("至少要选择一列","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) Return End If For i As Integer = 0 To nms.count -1 For Each nm As String In nms tb.Table.Cols(nm).Visible = false Next Next
Dim bbt As WinForm.Button = Forms("组合筛选").Controls("Button1") bbt.PerformClick
实现效果:
此主题相关图片如下:21.png
Button1按钮事件代码:【实现表列宽自动充满窗体】
Dim ts() As String = {"table1"}
For Each s As String In ts Dim t As Table = e.Form.controls(s).Table Dim width As Double = t.grid.width - t.grid.cols(0).widthdisplay Dim sum As Double = 0 For Each c As object In t.grid.cols If c.index > 0 AndAlso c.visible = True Then sum += c.widthdisplay End If Next For Each c As object In t.grid.cols If c.index > 0 AndAlso c.visible = True Then c.width = c.widthdisplay/sum*width End If Next Next
|