Public Class lov Public RES As Integer = 0 Public SelRow As DataRowView Dim first As Boolean = False ' Dim DA As OracleClient.OracleDataAdapter ' Dim vCMD As OracleClient.OracleCommand Dim Dt As New DataTable Dim VSql As String Dim work As Boolean Dim A As New System.Text.StringBuilder #Region "New Function" Public Sub New() InitializeComponent() End Sub Public Sub New(ByVal Dt As DataTable) ' 이 호출은 Windows Form 디자이너에 필요합니다. InitializeComponent() Me.BindingSource1.DataSource = Dt Me.fpspread1.DataSource = Me.BindingSource1 'Me.OK_Button.PerformClick() ' InitializeComponent() 호출 뒤에 초기화 코드를 추가하십시오. End Sub 'Public Sub New(ByVal Connection As OracleClient.OracleConnection, ByVal Sql As String) ' ' 이 호출은 Windows Form 디자이너에 필요합니다. ' InitializeComponent() ' DA = New OracleClient.OracleDataAdapter(Sql, Connection) ' Dt = New DataTable ' DA.Fill(Dt) ' DA = Nothing ' Me.BindingSource1.DataSource = Dt ' Me.fpspread1.DataSource = Me.BindingSource1 ' 'Me.OK_Button.PerformClick() ' ' InitializeComponent() 호출 뒤에 초기화 코드를 추가하십시오. 'End Sub 'Public Sub New(ByVal cmd As OracleClient.OracleCommand) ' ' 이 호출은 Windows Form 디자이너에 필요합니다. ' InitializeComponent() ' vCMD = cmd ' DA = New OracleClient.OracleDataAdapter(vCMD) ' Dt = New DataTable ' DA.Fill(Dt) ' DA = Nothing ' Me.BindingSource1.DataSource = Dt ' Me.fpspread1.DataSource = Me.BindingSource1 ' 'Me.OK_Button.PerformClick() ' ' InitializeComponent() 호출 뒤에 초기화 코드를 추가하십시오. 'End Sub #End Region #Region "OK/CANCEL 버튼" Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_ok.Click SelRow = Me.BindingSource1.Current Me.DialogResult = System.Windows.Forms.DialogResult.OK Me.Close() End Sub Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_cancel.Click Me.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.Close() End Sub #End Region Public Sub NOTICE(ByVal MSG As String, ByVal Src As Object) On Error Resume Next If Src.GetType.Name.ToUpper = "TOOLSTRIPSTATUSLABEL" Then CType(Src, ToolStripStatusLabel).Text = "▶ " & MSG & Space(1) ElseIf Src.GetType.Name.ToUpper = "LABEL" Then CType(Src, Label).Text = "▶ " & MSG & Space(1) & "(" & Now.ToString & ")" End If My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Hand) End Sub Public Sub NOTICE(ByVal MSG As String, ByVal FCOLOR As Color, ByVal Src As Windows.Forms.ToolStripStatusLabel) Src.Text = "▶ " & MSG & Space(1) & "(" & Now.ToString & ")" Src.ForeColor = FCOLOR My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Hand) End Sub Public Sub NOTICE(ByVal MSG As String, ByVal FCOLOR As Color, ByVal Src As Windows.Forms.ToolStripLabel) Src.Text = "▶ " & MSG & Space(1) & "(" & Now.ToString & ")" Src.ForeColor = FCOLOR My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Hand) End Sub Public Sub NoticeDel(ByVal Src As Windows.Forms.ToolStripStatusLabel) Src.Text = "▶" End Sub Private Sub fpspread1_CellDoubleClick(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.CellClickEventArgs) Handles fpspread1.CellDoubleClick Me.bt_ok.PerformClick() End Sub 'Private Sub fpspread1_EnterCell(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.EnterCellEventArgs) Handles fpspread1.EnterCell ' NOTICE(Me.fpspread1_Sheet1.ActiveRowIndex & "/" & Me.fpspread1_Sheet1.ActiveColumnIndex & " : 엔터(ENTER)키는 현재항목을 선택 , ESC 키를 누르면 검색창으로 이동합니다.", Color.Blue, Me.lb_msg) 'End Sub Private Sub fpspread1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles fpspread1.GotFocus If Me.fpspread1_Sheet1.Rows.Count = 0 Then NOTICE("선택 가능한 목록이 없습니다", Color.Red, Me.lb_msg) Me.tb_searchText.Focus() Else NOTICE("엔터(ENTER)키는 현재항목을 선택 , ESC 키를 누르면 검색창으로 이동합니다.", Color.Blue, Me.lb_msg) 'MsgBox("sdf") End If End Sub Private Sub Lov_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated Select Case Me.fpspread1.ActiveSheet.RowCount Case 0 Me.bt_cancel.PerformClick() Case 1 Me.bt_ok.PerformClick() Case Else Me.tb_searchText.Focus() End Select End Sub ''' ''' 사용하지않음 ''' ''' Private Sub FindStr() work = True Dim Frow, Fcol As Integer Dim Colname As String = Me.fpspread1.ActiveSheet.Columns(Me.fpspread1.ActiveSheet.ActiveColumnIndex).Label Dim SearchStr As String = InputBox("[" & Colname & "] 열에서 검색할 문자를 입력하세요.", "검색문자를 입력하세요") Me.fpspread1.Search(Me.fpspread1.ActiveSheetIndex, SearchStr, False, False, False, True, 0, Me.fpspread1.ActiveSheet.ActiveColumnIndex, Me.fpspread1.ActiveSheet.RowCount, Me.fpspread1.ActiveSheet.ActiveColumnIndex, Frow, Fcol) If Frow >= 0 AndAlso Fcol >= 0 Then '//검색됫다면 Me.first = True Me.fpspread1.ActiveSheet.SetActiveCell(Frow, Fcol) SendKeys.Send("{RIGHT}") SendKeys.Send("{LEFT}") Me.lb_msg.Text = "줄번호 = " & Me.fpspread1.ActiveSheet.ActiveRowIndex + 1 My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Exclamation) Else Me.lb_msg.Text = SearchStr & "로 검색된 값이 없습니다" My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Hand) End If End Sub Private Sub Lov_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Me.fpspread1.EnterToNextItem() End Sub ''' ''' where 절을 생성한후 리턴(모든 열에대한 같은 where like 절 ''' ''' ''' Private Function WhereState() As String A.Remove(0, A.Length) For i As Integer = 0 To Me.Dt.Columns.Count - 1 If Dt.Columns(i).DataType.Name.ToUpper = "STRING" Then A.Append(IIf(i = 0, "", Space(1) & "or ") & Dt.Columns(i).Caption & " like '" & Me.tb_searchtext.Text & "%'") End If Next Return A.ToString End Function Private Sub fpspread1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles fpspread1.KeyUp Select Case e.KeyCode Case Keys.Escape Me.tb_searchtext.Focus() Case Keys.Enter Me.bt_ok.PerformClick() End Select End Sub Private Sub TextBox1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles tb_searchtext.GotFocus NOTICE("방향키(↓)를 누르면 하단목록으로 이동합니다", Color.Blue, Me.lb_msg) End Sub Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tb_searchtext.KeyDown Select Case e.KeyCode Case Keys.Down Me.fpspread1.Focus() If Me.fpspread1_Sheet1.Rows.Count = 1 Then Me.bt_ok.PerformClick() '//한것박에없을경우는 바로 그것이므로 바로 커밋한다. Case Keys.Escape Me.bt_cancel.PerformClick() End Select End Sub Private Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles tb_searchtext.TextChanged Me.BindingSource1.Filter = Me.WhereState End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.tb_searchtext.Focus() End Sub End Class