Imports System.Text
Imports System.IO
Public Class MyListView
Private AutoView As Boolean = False '//ÀÚµ¿À¸·Î ¸®ºäÀdz»¿ëÀ» Äõ¸®ºí·°¿¡Ç¥½ÃÇÒÁö
Private var_AutoDelete As Boolean = True '//Delte۸¦ ´·¶À»¶§ ÀÚµ¿À¸·Î rowid¸¦ ÀÌ¿ëÇØ¼ »èÁ¦ÇÑ´Ù.
Private VAR_ENABLE_MYKEY As Boolean = True
Private var_enterkey As Boolean = True
'''
''' ¿£ÅÍ۸¦ ´©¸£¸é Æ÷Ä¿½º¸¦ À̵¿Çմϱî?
'''
'''
_
Public Property DB_Enable_EnterKey() As Boolean
Get
Return var_enterkey
End Get
Set(ByVal value As Boolean)
var_enterkey = value
End Set
End Property
'''
''' ÀÌ °³Ã¼¿¡ Ä¿¼¸¦ À̵¿ÇÕ´Ï´Ù.
'''
'''
Public Sub DB_SetFocus()
If Me.Items.Count <= 0 Then
MsgBox("ºä µ¥ÀÌÅͰ¡ Á¸ÀçÇÏÁö ¾Ê½À´Ï´Ù", MsgBoxStyle.Information, "È®ÀÎ")
Else
Me.Focus()
End If
End Sub
'''
''' ±âº» ¼ÂÆ®µÈ Ű ENTER/SHIFT+KEY/DELETE ¸¦ ºñȰ¼ºÈÇÕ´Ï´Ù.
'''
'''
'''
'''
_
Public Property DB_Enable_MyKey() As Boolean
Get
Return (VAR_ENABLE_MYKEY)
End Get
Set(ByVal value As Boolean)
VAR_ENABLE_MYKEY = value
End Set
End Property
'''
''' DELETE ۰¡ ´·ÇÀ»¶§ ¼±ÅõǾÆÀÌÅÛÀÇ 0¹øÀç °ªÀ» ROWID·Î »èÁ¦ÇÕ´Ï´Ù
'''
'''
'''
'''
_
Public Property DB_Enable_DelKey() As Boolean
Get
Return var_AutoDelete
End Get
Set(ByVal value As Boolean)
var_AutoDelete = value
End Set
End Property
'''
''' ÀÚµ¿À¸·Î ¸®ºäÀÇ ³»¿ëÀ» ¼³Á¤µÈ Äõ¸®ºí·°¿¡ Ç¥½ÃÇÕ´Ï´Ù selectedindexchanged ÇÔ¼ö°¡ È£ÃâµË´Ï´Ù.
'''
'''
'''
_
Public Property DB_Autoview() As Boolean
Get
Return AutoView
End Get
Set(ByVal value As Boolean)
AutoView = value
End Set
End Property
'''
''' ¸ðµç °³Ã¼¸¦ ¼±ÅÃÇÕ´Ï´Ù.
'''
'''
Public Sub ITEM_SELECT()
For Each A As ListViewItem In Me.Items
A.Checked = True
Next
End Sub
'''
''' ¸ðµç °³Ã¼ÀÇ ¼±ÅÃÀ» ÇØÁ¦ÇÕ´Ï´Ù.
'''
'''
Public Sub ITEM_UNSELECT()
For Each A As ListViewItem In Me.Items
A.Checked = False
Next
End Sub
'''
''' ¼±Åà ¹ÝÀü
'''
'''
Public Sub ITEM_DESELECT()
For Each A As ListViewItem In Me.Items
A.Checked = IIf(A.Checked, False, True)
Next
End Sub
'''
''' ¼±ÅûèÁ¦
'''
'''
Public Sub ITEM_SELECTDEL()
For Each A As ListViewItem In Me.Items
If A.Checked Then A.Remove()
Next
End Sub
'''
''' ¸®½ºÆ®ºä °¢¿ÀÌ Å©±â¸¦ È®ÀÎÇÕ´Ï´Ù.
'''
'''
Public Sub COLSIZE_SAVE()
Dim a As New MyINI2(My.Application.Info.DirectoryPath & "\LISTVIEW.INI")
For Each COL As ColumnHeader In Me.Columns
a.Write(Me.Parent.Name & "-" & Me.Name, "COLSIZE" & COL.Index.ToString, COL.Width)
Next
End Sub
'''
''' ¸®½ºÆ®ºä °¢¿ÀÇ Å©±â¸¦ ÆÄÀϷκÎÅÍ ºÒ·¯¿É´Ï´Ù.
'''
'''
Public Sub COLSIZE_LOAD()
Dim FILEname As String = My.Application.Info.DirectoryPath & "\LISTVIEW.INI"
Dim a As New MyINI2(My.Application.Info.DirectoryPath & "\LISTVIEW.INI")
If Not File.Exists(FILEname) Then
MsgBox("¿³Êºñ ÆÄÀÏÀÌ Á¸ÀçÇÏÁö ¾Ê½À´Ï´Ù", MsgBoxStyle.Critical, "¿³Êºñ¼³Á¤-¿À·ù")
COLSIZE_SAVE()
Return
End If
'MsgBox("PARENT" & Me.Parent.Name.ToString & "/" & Me.Parent.Text)
For Each COL As ColumnHeader In Me.Columns
'MsgBox(COL.Index)
'a.Write(Me.Parent.Name, "COLSIZE" & COL.Index.ToString, File, COL.Width)
Try
COL.Width = a.Read(Me.Parent.Name & "-" & Me.Name, "COLSIZE" & COL.Index.ToString)
Catch ex As Exception '//¾øÀ»°æ¿ì¿¡´Â ¿¡·¯¸¦ ³»¹Ç·Î ±×³É ³ª°£´Ù
End Try
Next
End Sub
Public Sub FileSave()
Dim SD As New SaveFileDialog
SD.Filter = "ÅÇÀ¸·Î ºÐ¸®µÈ ÆÄÀÏ(*.TXT)|*.TXT|ÄÞ¸¶·Î ºÐ¸®µÈ ÆÄÀÏ(*.CSV)|*.CSV|Excel WorkSheet(*.XLS)|*.XLS|XML Excel WorkSheet|*.xml|HTML(*.HTML)|*.HTML"
SD.FilterIndex = 1
SD.RestoreDirectory = True
If SD.ShowDialog() = DialogResult.OK Then
Select Case SD.FilterIndex
Case 1
ExportToTXT(SD.FileName)
End Select
End If
End Sub
Public Function ExportToTXT(ByVal FileName As String, Optional ByVal StartPosition As Short = 2, Optional ByVal NotePadOpen As Boolean = False) As Boolean
Dim FS As New FileStream(FileName, FileMode.Create)
'Dim BW As New BinaryWriter(FS, System.Text.Encoding.Default)
Dim SW As New StreamWriter(FS, System.Text.Encoding.Default)
Dim rowIndex As Integer = 1 '¿¢¼¿ÀÇ Çà°ª
Dim Rrowindex As Integer = 1
Dim colIndex As Integer = 0 '¿¢¼¿ÀÇ ¿°ª
Dim RcolIndex As Integer = 0
Windows.Forms.Cursor.Current = Cursors.WaitCursor '//¸¶¿ì½º¸¦ ´ë±â·Î º¯È¯
Try
Dim LV As ListViewItem
Dim la As ListViewItem.ListViewSubItem
Dim SubBuf As StringBuilder
Dim Aa As ColumnHeader
'--¿¸Ó¸®±Û ³»º¸³»±â
For Each Aa In Me.Columns
'MsgBox(Aa.Text)
colIndex += 1
If colIndex >= StartPosition Then
RcolIndex += 1
SW.Write(Aa.Text & vbTab)
'excelApp.Cells(1, RcolIndex) = Aa.Text
End If
Next
SW.Write(vbCrLf)
'- ¿µ¥ÀÌÅÍ ³»º¸³»±â
For Each LV In Me.Items
rowIndex += 1 '//Çà°ªÀ» 1°³ Áõ°¡½ÃŲ´Ù.
colIndex = 0 '//¿°ªÀº ÃʱâÈÇÑ´Ù.
RcolIndex = 0 '//¿°ªÀº ÃʱâÈÇÑ´Ù.
SubBuf = New StringBuilder '//¹®ÀÚ¿ ÀúÀå¹öÆÛ ÃʱâÈ
For Each la In LV.SubItems
colIndex += 1
If colIndex >= StartPosition Then
RcolIndex += 1
SW.Write(la.Text & vbTab) '//Ä÷³À» Ãß°¡ÇÑ´Ù.
End If
Next
SW.Write(vbCrLf)
Next
SW.Close()
FS.Close()
Return True
Catch exp As Exception
MessageBox.Show(exp.ToString)
SW.Close()
FS.Close()
Return False
End Try
End Function
End Class