※ DataGridView1.EndEdit()
※ 화면 변화 업데이트 제어
DataGridView1.SuspendLayout()
DataGridView1.ResumeLayout()
※ 컬럼 추가
Dim D As DataTable = DataGridView1.DataSource
'DGV.DataSource = Nothing
'D = New DataTable
For Each HD As String In {"no", "ctg", "w"}
D.Columns.Add(HD.Replace(Space(1), "_").Trim(), Type.GetType("System.String"))
Next
※ 아이템 추가
R = D.NewRow
R.Item("no") = D.Rows.Count
R.Item("ctg") = ComboBox1.Text
R.Item("w") = Replace(T.Trim(), "'", "''")
D.Rows.Add(R)
※ 중복제거
D = RemoveDuplicateRows(D, "w")
Public Function RemoveDuplicateRows(ByVal dTable As DataTable, ByVal colName As String) As DataTable
Dim hTable As Hashtable = New Hashtable()
Dim duplicateList As ArrayList = New ArrayList()
For Each drow As DataRow In dTable.Rows
If hTable.Contains(drow(colName)) Then
duplicateList.Add(drow)
Else
hTable.Add(drow(colName), String.Empty)
End If
Next
For Each dRow As DataRow In duplicateList
dTable.Rows.Remove(dRow)
Next
Return dTable
End Function
※ 유일한 항목 추출
DGV.DataSource = DT
Dim ctg As DataTable = DGV.DataSource.DefaultView.ToTable(True, "ctg")
If ctg.Rows.Count Then
ComboBox1.Items.Clear()
For Each R In ctg.Rows
ComboBox1.Items.Add(R.Item("ctg"))
Next
End If
※ DataGridView Row 에서 DataRow
DataGridViewRow.DataBoundItem은 Databound dataTable (dataview)의 현재 항목에 대한 dataViewRow를 제공합니다.
Dim drv as DataRowView = DGV.DataBoundItem
Dim dr as DataRow = drv.Row
i = CType(DGV.DataSource, DataTable).Rows.IndexOf(dr)
DGV.FirstDisplayedScrollingRowIndex = i '// 스크롤
※ 지정한 폴더에서 특정 형식의 파일명만 추출
Dim di As New DirectoryInfo(Application.StartupPath & "\User Data")
Dim fiArr As FileInfo() = di.GetFiles("*.xml")
Dim fri As FileInfo
ComboBox2.Items.Clear()
For Each fri In fiArr
ComboBox2.Items.Add(Path.GetFileNameWithoutExtension(fri.Name))
Next fri
※ DataGridView 이름별로 컬럼 다르게 설정
Select Case MyDGV.Name
Case "nhnIDs" : i = 1
Case "DGV" : i = 2
Case "LI" : i = 3
Case "RP" : i = 4
End Select
For Each HD As String In Choose(i, {"ck", "no", "아이디", "비밀번호", "작업횟수", "note"}, {"no", "ctg", "w"}, {"no", "단어"}, {"no", "old", "new"})
If Not D.Columns.Contains(HD) Then
If HD = "ck" Then
D.Columns.Add(HD.Trim(), Type.GetType("System.Boolean"))
Else
D.Columns.Add(HD.Trim(), Type.GetType("System.String"))
End If
End If
Next
MyDGV.DataSource = D
Private Sub TSM_Click(sender As Object, e As EventArgs) Handles TSM_REMOVE_ALL.Click, TSM_SELECT_ALL.Click, TSM_INVERT.Click, TSM_DESELECT_ALL.Click, TSM_REMOVE_SELECTED.Click, TSM_FILE_ADD.Click
Dim myItem As ToolStripMenuItem = CType(sender, ToolStripMenuItem)
Dim cms As ContextMenuStrip = CType(myItem.Owner, ContextMenuStrip)
If (TypeOf cms.SourceControl Is DataGridView) Then
Dim MyDGV As DataGridView = cms.SourceControl
MyDGV.EndEdit()
MyDGV.SuspendLayout()
'// 프로그래밍
MyDGV.ResumeLayout()
ElseIf (TypeOf cms.SourceControl Is ListBox) Then
Dim LB As ListBox = cms.SourceControl
LB.BeginUpdate()
'// 프로그래밍
LB.EndUpdate()
End If
End Sub
_sourceBitmap = Bitmap.FromFile("Settings\6e78fa096f9750e12db6.png", False)
Select Case _sourceBitmap.PixelFormat
Case PixelFormat.Format32bppArgb
Case PixelFormat.Format32bppPArgb
Case PixelFormat.Format32bppRgb
Case Else
Dim tempBitmap As New Bitmap(_sourceBitmap.Width, _sourceBitmap.Height, PixelFormat.Format32bppArgb)
Dim g As Graphics = Graphics.FromImage(tempBitmap)
g.DrawImage(_sourceBitmap, New Rectangle(0, 0, tempBitmap.Width, tempBitmap.Height))
g.Dispose()
_sourceBitmap = tempBitmap.Clone
tempBitmap.Dispose()
End Select
Dim C As Control = Me
Do
C = Me.GetNextControl(C, True)
If C IsNot Nothing Then
If (TypeOf C Is GroupBox) Then
ElseIf (TypeOf C Is TextBox) Then
ElseIf (TypeOf C Is CheckBox) Then
ElseIf (TypeOf C Is RadioButton) Then
ElseIf (TypeOf C Is DataGridView) Then
ElseIf (TypeOf C Is DataGridView) Then
ElseIf (TypeOf C Is ListBox) Then
ElseIf (TypeOf C Is PictureBox) Then
End If
End If
Loop Until C Is Nothing
Private Sub DataGridViewAutoSizeColumn(ByRef MyDataGridView As DataGridView)
For Each Col As DataGridViewColumn In MyDataGridView.Columns
'Col.ReadOnly = True
Col.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells
Next
End Sub
Private Sub TextBox_KeyDown(sender As Object, e As KeyEventArgs) Handles TextBox12.KeyDown, TextBox14.KeyDown, TextBox7.KeyDown, TextBox8.KeyDown
If e.KeyCode <> 13 Then Return
Dim T As TextBox = CType(sender, TextBox)
If T.Name = TextBox12.Name Then
Button7.PerformClick()
ElseIf T.Name = TextBox14.Name Then
Button8.PerformClick()
ElseIf T.Name = TextBox7.Name Then
Button2.PerformClick()
ElseIf T.Name = TextBox8.Name Then
Button3.PerformClick()
End If
End Sub
TextBox14.Focus()
File.Copy(strFileName, fName)
'자료' 카테고리의 다른 글
[php] curl을 이용하여 post, get 사용 (0) | 2020.08.17 |
---|---|
[C#/vb.net] 두 날짜 및 시간 사이에(구간)에 지정한 특정 날자시간이 포함되는지 확인하는 함수 (0) | 2020.08.17 |
[C#/vb.net] 수학 함수 (0) | 2020.08.17 |
[C#/vb.net] HTML 정리 및 테그 제거 (0) | 2020.08.17 |
[C#/vb.net] 오류 로그확인 및 오류 메시지 저장 (0) | 2020.08.16 |