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. ComboBox DisplayMember and ValueMember without database

ComboBox DisplayMember and ValueMember without database

Scheduled Pinned Locked Moved Visual Basic
databasetutorialquestion
5 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.
  • I Offline
    I Offline
    ivo75
    wrote on last edited by
    #1

    How to use ComboBox DisplayMember and ValueMember without database?

    I L 2 Replies Last reply
    0
    • I ivo75

      How to use ComboBox DisplayMember and ValueMember without database?

      I Offline
      I Offline
      ivo75
      wrote on last edited by
      #2

      I use this

      color1 = New BaseColor() {iTextSharp.text.BaseColor.BLACK, iTextSharp.text.BaseColor.BLUE, iTextSharp.text.BaseColor.CYAN, iTextSharp.text.BaseColor.DARK_GRAY, iTextSharp.text.BaseColor.GRAY, iTextSharp.text.BaseColor.GREEN, iTextSharp.text.BaseColor.LIGHT_GRAY, iTextSharp.text.BaseColor.MAGENTA, iTextSharp.text.BaseColor.ORANGE, iTextSharp.text.BaseColor.PINK, iTextSharp.text.BaseColor.RED, iTextSharp.text.BaseColor.WHITE, iTextSharp.text.BaseColor.YELLOW}
      color2 = New String() {"Черен", "Син", "Циан", "Тъмно сиво", "Сиво", "Зелено", "Светло сиво", "Магента", "Оранжево", "Розово", "Червено", "Бяло", "Жълто"}
      For i = 0 To color1.Length - 1
      ComboBox2.Items.Add(color2(i))
      Next

      If File.Exists(TextBox1.Text) Then
      File.Delete(TextBox1.Text)
      Dim bf As BaseFont = BaseFont.CreateFont(k & "\\arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)
      Dim bc As BaseColor
      bc = color1(ComboBox2.SelectedIndex)
      ' bc = CType(iTextSharp.text.BaseColor.BLACK, "BaseColor" & "." & color1(ComboBox2.SelectedIndex))

              AddWatermarkText(TextBox3.Text, TextBox1.Text, TextBox2.Text, bf, NumericUpDown1.Value, bc, 50.0F, NumericUpDown2.Value)
          Else
              Dim bf As BaseFont = BaseFont.CreateFont(k & "\\\\arial.ttf", BaseFont.IDENTITY\_H, BaseFont.EMBEDDED)
              Dim bc As BaseColor
              bc = color1(ComboBox2.SelectedIndex)
              ' bc = CType(iTextSharp.text.BaseColor.BLACK, "BaseColor" & "." & color1(ComboBox2.SelectedIndex))
      
              AddWatermarkText(TextBox3.Text, TextBox1.Text, TextBox2.Text, bf, NumericUpDown1.Value, bc, 50.0F, NumericUpDown2.Value)
      
          End If
      
      1 Reply Last reply
      0
      • I ivo75

        How to use ComboBox DisplayMember and ValueMember without database?

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

        There is no need for a database, a DataTable, or anything pre-existing. You want some class, with at least two public properties, and a collection of instances of said class. The collection (e.g. a List) becomes your DataSource; the one string property your DisplayMember, and the other property your ValueMember; so you need to provide the names of those properties in the "DisplayMember" and "ValueMember" properties of your Control (e.g. ComboBox). :)

        Luc Pattyn [My Articles] Nil Volentibus Arduum

        I 1 Reply Last reply
        0
        • L Luc Pattyn

          There is no need for a database, a DataTable, or anything pre-existing. You want some class, with at least two public properties, and a collection of instances of said class. The collection (e.g. a List) becomes your DataSource; the one string property your DisplayMember, and the other property your ValueMember; so you need to provide the names of those properties in the "DisplayMember" and "ValueMember" properties of your Control (e.g. ComboBox). :)

          Luc Pattyn [My Articles] Nil Volentibus Arduum

          I Offline
          I Offline
          ivo75
          wrote on last edited by
          #4

          This work for me thanks

          Public Class WatermarColors
          Private mWatermarkColor As iTextSharp.text.BaseColor
          Private mWatermarkBGName As String

          Public Sub New(ByVal name As String, ByVal code As iTextSharp.text.BaseColor)
          
              mWatermarkBGName = name
              mWatermarkColor = code
          End Sub
          
          Public Property WatermarkBGNames() As String
              Get
                  Return mWatermarkBGName
              End Get
              Set(ByVal value As String)
                  mWatermarkBGName = value
              End Set
          End Property
          
          Public Property WatermarkColors() As iTextSharp.text.BaseColor
              Get
                  Return mWatermarkColor
              End Get
              Set(ByVal value As iTextSharp.text.BaseColor)
                  mWatermarkColor = value
              End Set
          End Property
          
          Public Overrides Function ToString() As String
          
              Return mWatermarkBGName
          End Function
          

          End Class

          color1 = New BaseColor() {iTextSharp.text.BaseColor.BLACK, iTextSharp.text.BaseColor.BLUE, iTextSharp.text.BaseColor.CYAN, iTextSharp.text.BaseColor.DARK_GRAY, iTextSharp.text.BaseColor.GRAY, iTextSharp.text.BaseColor.GREEN, iTextSharp.text.BaseColor.LIGHT_GRAY, iTextSharp.text.BaseColor.MAGENTA, iTextSharp.text.BaseColor.ORANGE, iTextSharp.text.BaseColor.PINK, iTextSharp.text.BaseColor.RED, iTextSharp.text.BaseColor.WHITE, iTextSharp.text.BaseColor.YELLOW}
          color2 = New String() {"Черен", "Син", "Циан", "Тъмно сиво", "Сиво", "Зелено", "Светло сиво", "Магента", "Оранжево", "Розово", "Червено", "Бяло", "Жълто"}
          For i = 0 To color1.Length - 1
          CboWatermarkColor.Items.Add(New WatermarColors(color2(i), color1(i)))
          Next

          Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
          If File.Exists(TextBox1.Text) Then
          File.Delete(TextBox1.Text)
          Dim bf As BaseFont = BaseFont.CreateFont(k & "\\arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)
          Dim bc As BaseColor
          Dim WatermarkSelectColor As WatermarColors

                  WatermarkSelectColor = CType(CboWatermarkColor.SelectedItem, WatermarColors)
          
                  bc = WatermarkSelectColor.WatermarkColors
                  
                  AddWatermarkText(TextBox3.Text, TextBox1.Text, TextBox2.Text, bf, NumericUpDown1.Value, bc, 50.0F, NumericUpDown2.Value)
              Else
                  Dim bf As BaseFont = BaseFont.CreateFont(k & "\\\\arial.ttf", BaseFont.IDENTITY\_H, BaseFont.EMBEDDED)
                  Dim bc As Base
          
          A 1 Reply Last reply
          0
          • I ivo75

            This work for me thanks

            Public Class WatermarColors
            Private mWatermarkColor As iTextSharp.text.BaseColor
            Private mWatermarkBGName As String

            Public Sub New(ByVal name As String, ByVal code As iTextSharp.text.BaseColor)
            
                mWatermarkBGName = name
                mWatermarkColor = code
            End Sub
            
            Public Property WatermarkBGNames() As String
                Get
                    Return mWatermarkBGName
                End Get
                Set(ByVal value As String)
                    mWatermarkBGName = value
                End Set
            End Property
            
            Public Property WatermarkColors() As iTextSharp.text.BaseColor
                Get
                    Return mWatermarkColor
                End Get
                Set(ByVal value As iTextSharp.text.BaseColor)
                    mWatermarkColor = value
                End Set
            End Property
            
            Public Overrides Function ToString() As String
            
                Return mWatermarkBGName
            End Function
            

            End Class

            color1 = New BaseColor() {iTextSharp.text.BaseColor.BLACK, iTextSharp.text.BaseColor.BLUE, iTextSharp.text.BaseColor.CYAN, iTextSharp.text.BaseColor.DARK_GRAY, iTextSharp.text.BaseColor.GRAY, iTextSharp.text.BaseColor.GREEN, iTextSharp.text.BaseColor.LIGHT_GRAY, iTextSharp.text.BaseColor.MAGENTA, iTextSharp.text.BaseColor.ORANGE, iTextSharp.text.BaseColor.PINK, iTextSharp.text.BaseColor.RED, iTextSharp.text.BaseColor.WHITE, iTextSharp.text.BaseColor.YELLOW}
            color2 = New String() {"Черен", "Син", "Циан", "Тъмно сиво", "Сиво", "Зелено", "Светло сиво", "Магента", "Оранжево", "Розово", "Червено", "Бяло", "Жълто"}
            For i = 0 To color1.Length - 1
            CboWatermarkColor.Items.Add(New WatermarColors(color2(i), color1(i)))
            Next

            Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
            If File.Exists(TextBox1.Text) Then
            File.Delete(TextBox1.Text)
            Dim bf As BaseFont = BaseFont.CreateFont(k & "\\arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)
            Dim bc As BaseColor
            Dim WatermarkSelectColor As WatermarColors

                    WatermarkSelectColor = CType(CboWatermarkColor.SelectedItem, WatermarColors)
            
                    bc = WatermarkSelectColor.WatermarkColors
                    
                    AddWatermarkText(TextBox3.Text, TextBox1.Text, TextBox2.Text, bf, NumericUpDown1.Value, bc, 50.0F, NumericUpDown2.Value)
                Else
                    Dim bf As BaseFont = BaseFont.CreateFont(k & "\\\\arial.ttf", BaseFont.IDENTITY\_H, BaseFont.EMBEDDED)
                    Dim bc As Base
            
            A Offline
            A Offline
            Andy_L_J
            wrote on last edited by
            #5

            Dim lst as New List(Of WatermarkColor)
            lst.Add(New WatermarkColor(watermarkBGName,watermarkColor)

            cboWatermarkColors.DataSource = lst
            cboWatermarkColors.DisplayMember = "WatermarkBGName"
            cboWatermarkColors.ValueMember = "WatermarkColor"

            I don't speak Idiot - please talk slowly and clearly 'This space for rent' Driven to the arms of Heineken by the wife

            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