自定义控件属性窗口更新求教各位,谢谢!!!
我在学习编写一个自定义控件,遇到一个问题,在设计模式下,打开控件的一个属性:编辑列,打开后如第一幅图,再点击编辑列里的添加命定(添加列.ShowDialog()),打开添加列窗口。
我想实现当按下添加列里的确定时,编辑列里的listbox1的内容就跟着变化,下面的代码中(编辑列窗口里的Public Function arrli)也执行(第三幅图),但编辑列里的listbox1的内容却没有变化
还请大家予以帮助,谢谢!!!
添加列窗口代码:
Imports System.Windows.Forms.Design
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Drawing.Design
Public Class 添加列
Public Col As Short
Private Sub 添加列_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Col = 编辑列.Col
If Col = 0 Then
TextBox1.Text = "CoLumns"
Else
TextBox1.Text = "CoLumns" & Col
End If
ComboBox1.Items.Add("DataGridViewButtonColumn")
ComboBox1.Items.Add("DataGridViewCheckBoxColumn")
ComboBox1.Items.Add("DataGridViewComboBoxColumn")
ComboBox1.Items.Add("DataGridViewImageColumn")
ComboBox1.Items.Add("DataGridViewLinkColumn")
ComboBox1.Items.Add("DataGridViewTextBoxColumn")
ComboBox1.SelectedIndex = 5
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' Me.DialogResult = System.Windows.Forms.DialogResult.OK
If Col = 0 Then
Col = 1
Else
Col += 1
End If
编辑列.arrli(Col)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Close()
End Sub
End Class
编辑列窗口代码:
Imports System.ComponentModel
Imports System.Drawing.Design
Public Class 编辑列
Public Col As Short
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
添加列.ShowDialog()
End Sub
Public Function arrli(ByVal newcol As Short)
Col = newcol
For i As Short = 1 To Col
Me.ListBox1.Items.Add(i)
MsgBox(ListBox1.Items.Count & "FfffffffffffffffffFF" & Col)
Next
Me.Refresh()
End Function
End Class
[解决办法]
我已经研究出来几个控件了,可以的话把代码发来共同研究一下