Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Array declaration and asigning value of array to combobox

Array declaration and asigning value of array to combobox

Scheduled Pinned Locked Moved Visual Basic
cssdesigndata-structurestutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KIDYA
    wrote on last edited by
    #1

    Hello Experts!! I am declaring one array (having size 10) as an integer and bind array data to grid combobox.It works well but in combobox it shows values as well as zeros....means if array contains 3 values then remaining values shows zero(remaining 7). How to taggle with this? Combo shows like this->1,2,3,0,0,0,0,0,0,0...I dont want that zeros My code is <pre>Dim o As New design Dim i As Integer = 0 Dim rowArray As String() Dim no(10) As Integer //Declaration rssearch = New ADODB.Recordset rssearch.Open("select srno from design", con, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockPessimistic) While Not rssearch.EOF o = New design o.dsrno = rssearch.Fields("srno").Value Dim row1() As String = {o.dsrno} Dim rows() As Object = {row1} For Each rowArray In rows no(i) = rowArray(0) // Assign value one by one i = i + 1 Next rowArray o = Nothing o = New design rssearch.MoveNext() 'i = i + 1 End While CType(dgvbottom.Columns(8), DataGridViewComboBoxColumn).DataSource = no // Display values in combo

    C L 2 Replies Last reply
    0
    • K KIDYA

      Hello Experts!! I am declaring one array (having size 10) as an integer and bind array data to grid combobox.It works well but in combobox it shows values as well as zeros....means if array contains 3 values then remaining values shows zero(remaining 7). How to taggle with this? Combo shows like this->1,2,3,0,0,0,0,0,0,0...I dont want that zeros My code is <pre>Dim o As New design Dim i As Integer = 0 Dim rowArray As String() Dim no(10) As Integer //Declaration rssearch = New ADODB.Recordset rssearch.Open("select srno from design", con, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockPessimistic) While Not rssearch.EOF o = New design o.dsrno = rssearch.Fields("srno").Value Dim row1() As String = {o.dsrno} Dim rows() As Object = {row1} For Each rowArray In rows no(i) = rowArray(0) // Assign value one by one i = i + 1 Next rowArray o = Nothing o = New design rssearch.MoveNext() 'i = i + 1 End While CType(dgvbottom.Columns(8), DataGridViewComboBoxColumn).DataSource = no // Display values in combo

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      This is why you should use dynamic lists instead of fixed arrays. The control is doing exactly what you asked it to. Use List<int> instead.

      Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

      1 Reply Last reply
      0
      • K KIDYA

        Hello Experts!! I am declaring one array (having size 10) as an integer and bind array data to grid combobox.It works well but in combobox it shows values as well as zeros....means if array contains 3 values then remaining values shows zero(remaining 7). How to taggle with this? Combo shows like this->1,2,3,0,0,0,0,0,0,0...I dont want that zeros My code is <pre>Dim o As New design Dim i As Integer = 0 Dim rowArray As String() Dim no(10) As Integer //Declaration rssearch = New ADODB.Recordset rssearch.Open("select srno from design", con, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockPessimistic) While Not rssearch.EOF o = New design o.dsrno = rssearch.Fields("srno").Value Dim row1() As String = {o.dsrno} Dim rows() As Object = {row1} For Each rowArray In rows no(i) = rowArray(0) // Assign value one by one i = i + 1 Next rowArray o = Nothing o = New design rssearch.MoveNext() 'i = i + 1 End While CType(dgvbottom.Columns(8), DataGridViewComboBoxColumn).DataSource = no // Display values in combo

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        hi, an int array of dimension 10 always contains 10 numeric values, they get initialized at zero. solutions: 1. give your array the right dimension 2. use a collection instead of an array, say a List Of Int :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


        K 1 Reply Last reply
        0
        • L Luc Pattyn

          hi, an int array of dimension 10 always contains 10 numeric values, they get initialized at zero. solutions: 1. give your array the right dimension 2. use a collection instead of an array, say a List Of Int :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


          K Offline
          K Offline
          KIDYA
          wrote on last edited by
          #4

          List of (int :-D ), worked..Thanx...

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups