在ListBox中显示字段

时间:2018-04-09 12:18:15

标签: .net vb.net

很高兴加入你们.. 请Gentelman .. 如何在Listbox1中使用相同的代码显示字段Localite From table Departement .. 先感谢您。 热忱。 阿比丁

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Database_Connection()
    InfoCommand = New SqlCommand("SELECT * FROM Customers ORDER BY Prenom", Con)
    InfoAdapter = New SqlDataAdapter()
    InfoAdapter.SelectCommand = InfoCommand
    InfoTable = New DataTable()
    InfoAdapter.Fill(InfoTable)
    DataGridView1.DataSource = InfoTable


    ' ListBox1.DataSource = InfoTable   
    'From Departement where Localite 

End Sub

2 个答案:

答案 0 :(得分:0)

试试这段代码......

cmake_minimum_required (VERSION 2.8 FATAL_ERROR)
PROJECT(LSCM)
FIND_PACKAGE( OpenCV REQUIRED )
find_package( PCL 1.7 REQUIRED COMPONENTS common io visualization filters )
find_package( CGAL QUIET COMPONENTS )
if ( NOT CGAL_FOUND )
  message(STATUS "This project requires the CGAL library, and will not be compiled.")
  return()  
endif()

include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

include( CGAL_CreateSingleSourceCGALProgram )

find_package( Boost REQUIRED )
if ( NOT Boost_FOUND )
  message(STATUS "This project requires the Boost library, and will not be compiled.")
  return()  
endif()

SET(CMAKE_BUILD_TYPE "Debug")
SET(LIBRARY_OUTPUT_PATH "./lib")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
file(GLOB SOURCE_FILES ./*.cpp)

ADD_EXECUTABLE(Main ${SOURCE_FILES})
TARGET_LINK_LIBRARIES(Main ${OpenCV_LIBS} ${PCL_LIBRARIES} ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} -lCGAL -lm ) 
install (TARGETS Main DESTINATION ~/bin)

答案 1 :(得分:0)

只需创建一组新的命令,适配器和数据表。您可以使用相同的连接。适配器为您打开和关闭连接.DisplayMember是您希望在ListBox中可见的字段的名称。可以将ValueMembe设置为相同的字段,但将其设置为表的主键非常方便。

import unittest
import os.path
from dao.iotools.blbmktdata import *

class TestBlbMktData(unittest.TestCase):
    staticName='file1.csv'
    reportingName='file2.csv'
    corpName='file3.csv'
    fxName='file4.csv'
    holidayName='file5.csv'
    closeDataName='file6.csv'

    def print(self,data):
        print()
        print(len(data))
        print(data.head())
        print(data.dtypes)

    def read(self,name,func):
        return func(os.path.join(self.current_dir,name))

    def setUp(self):
        self.current_dir=os.path.dirname(os.path.abspath(__file__))

    def test_corp_act(self):
        self.print(self.read(self.corpName,readCorpAction))

    def test_static(self):
        self.print(self.read(self.staticName,readInstrumentStatic))

    def test_reporting(self):
        self.print(self.read(self.reportingName,readReportingDates))

    def test_fx(self):
        self.print(self.read(self.fxName,readFx))

    def test_holidays(self):
        self.print(self.read(self.holidayName,readHolidays))

    def test_close(self):
        self.print(self.read(self.closeDataName,readClosePrice))