473,398 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Multicolumn Combobox

Hi Guys
Can someone correct my code. I am trying to create a third column on a multicolumn combo box but the second column is overwritten with text from two columns (i.e. the second and third).

Here is my Code:


Expand|Select|Wrap|Line Numbers
  1.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  2.         'TODO: This line of code loads data into the 'PolicyInfoDataSet.tblPolicy_Information' table. You can move, or remove it, as needed.
  3.         Me.TblPolicy_InformationTableAdapter.Fill(Me.PolicyInfoDataSet.tblPolicy_Information)
  4.         'TODO: This line of code loads data into the 'PolicyInfoDataSet.tblCall_Transactions' table. You can move, or remove it, as needed.
  5.         Me.TblCall_TransactionsTableAdapter.Fill(Me.PolicyInfoDataSet.tblCall_Transactions)
  6.  
  7.         Dim Pol As DataTable = PolicyInfoDataSet.tblPolicy_Information
  8.         PolicyNoComboBox.DataSource = Pol
  9.         PolicyNoComboBox.DrawMode = DrawMode.OwnerDrawFixed
  10.     End Sub
  11.     Private Sub PolicyNoComboBox_DrawItem(sender As Object, e As System.Windows.Forms.DrawItemEventArgs) Handles PolicyNoComboBox.DrawItem
  12.         ' Draw the default background
  13.         e.DrawBackground()
  14.  
  15.         ' The ComboBox is bound to a DataTable,
  16.         ' so the items are DataRowView objects.
  17.         Dim drv As DataRowView = CType(PolicyNoComboBox.Items(e.Index), DataRowView)
  18.  
  19.         ' Retrieve the value of each column.
  20.         Dim PolID As String = drv("ID").ToString()
  21.         Dim PolNo As String = drv("Prosperity Policy No").ToString()
  22.         Dim Tel As String = drv("Telephone Cell").ToString()
  23.  
  24.  
  25.         '-----------------------------------------------------------------------------------------------------------------------
  26.  
  27.         ' Get the bounds for the first column
  28.         Dim r1 As Rectangle = e.Bounds
  29.         r1.Width = r1.Width / 3
  30.  
  31.         ' Draw the text on the first column
  32.         Using sb As SolidBrush = New SolidBrush(e.ForeColor)
  33.             e.Graphics.DrawString(PolID, e.Font, sb, r1)
  34.         End Using
  35.  
  36.         ' Draw a line to isolate the columns 
  37.         Using p As Pen = New Pen(Color.Black)
  38.             e.Graphics.DrawLine(p, r1.Right, 0, r1.Right, r1.Bottom)
  39.         End Using
  40.  
  41.         '---------------------------------------------------------------------------------------------------------------
  42.  
  43.         ' Get the bounds for the second column
  44.         Dim r2 As Rectangle = e.Bounds
  45.         r2.X = e.Bounds.Width / 3
  46.         r2.Width = r2.Width / 2
  47.  
  48.         ' Draw the text on the second column
  49.         Using sb As SolidBrush = New SolidBrush(e.ForeColor)
  50.             e.Graphics.DrawString(PolNo, e.Font, sb, r2)
  51.         End Using
  52.  
  53.         ' Draw a line to isolate the columns 
  54.         Using p As Pen = New Pen(Color.Black)
  55.             e.Graphics.DrawLine(p, r2.Right, 0, r2.Right, r1.Bottom)
  56.         End Using
  57.  
  58.  
  59.         '---------------------------------------------------------------------------------------------------------------
  60.  
  61.         ' Get the bounds for the third column
  62.         Dim r3 As Rectangle = e.Bounds
  63.         r3.X = e.Bounds.Width / 3
  64.         r3.Width = r3.Width / 3
  65.  
  66.         ' Draw the text on the third column
  67.         Using sb As SolidBrush = New SolidBrush(e.ForeColor)
  68.             e.Graphics.DrawString(Tel, e.Font, sb, r3)
  69.         End Using
  70.  
  71.         PolIDTextBox.Text = PolID
  72.         PhoneNoTextBox.Text = Tel
  73.     End Sub
May 29 '15 #1
0 1287

Sign in to post your reply or Sign up for a free account.

Similar topics

27
by: DraguVaso | last post by:
Hi, The Multi column comboBox is a well spoken control, that a lot of people desire, and a lot of people buildtheir own. I tested a lot of them, but none really was what i wanted to have. But...
0
by: Keith Smith | last post by:
How can this be done in C#...? http://www.codeguru.com/Cpp/controls/combobox/multicolumncombos/article.php/c1825/
0
by: jaYPee | last post by:
I'm wondering why if there is an example of using a multiplecolumn combobox in datagrid control. thanks in advance
6
by: Lars Netzel | last post by:
I have ask this before and I got a link to a solution where you actually show a new from on top of everything with a listbox in, where you can have multicolumns.. and that's what I use now.. That...
0
by: Lars Netzel | last post by:
It seems like more people than me are looking for something like this.. and I definately see a big benefit having one of these so it's strange to me that noone has made one. Is it possible to...
7
by: Aaron Smith | last post by:
I would like to try to make a combo box have multiple columns. Does anyone know of a good way to attempt this? I saw a project on thecodeproject to do this, I just didn't like the way it looked. I...
8
by: | last post by:
I am sure this has been asked and answered, but here goes anyway... VS.Net 2005, VB.Net How can you display more than one field in the displaymember property of a combobox inside the...
1
by: vijay dahite | last post by:
can anybody tell me how to write code for multicolumn combobox in vb6.0 plzzzz... vijay
1
by: Rod Haywood | last post by:
I'm trying to populate a multicolumn combo box with data from a sql query. First problem is that I have to click the down arrow in the cbox to see the first record. How do I change that? Second...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.