?
Solved

Listview bold

Posted on 2005-03-23
12
Medium Priority
?
1,568 Views
Last Modified: 2013-12-26
Hi,

I have a 9 column listview, How do make column 7 whole column bold.
0
Comment
Question by:aarontham
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +2
12 Comments
 
LVL 27

Expert Comment

by:Dabas
ID: 13619471
Hi aarontham:
In VB6 standard Listview, the answer is not what you want to hear.
Unless you create your own control, it cannot be done

Dabas
0
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 13619490
hi
u need to bold the 7th cloumn while adding the listitem itselft
try this

'=====================
Dim objLst As ListItem

    Set objLst = ListView1.ListItems.Add(, , "Your List item Text")
    objLst.SubItems(1) = "Column 2 content"
    objLst.SubItems(2) = "Column 3 content"
    objLst.SubItems(3) = "Column 4 content"
    objLst.SubItems(4) = "Column 5 content"
    objLst.SubItems(5) = "Column 6 content"
   
    objLst.SubItems(6) = "7 the Column content"
   
    'Bolding 7 the column
    objLst.ListSubItems(6).Bold = True
   
    objLst.SubItems(1) = "Column 8 content"
    objLst.SubItems(1) = "Column 9 content"

'=========================

;-)
Shiju
0
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 13619499
sorry  aarontham, there is a correction
try this

'=====================
Dim objLst As ListItem

   Set objLst = ListView1.ListItems.Add(, , "Your List item Text")
   objLst.SubItems(1) = "Column 2 content"
   objLst.SubItems(2) = "Column 3 content"
   objLst.SubItems(3) = "Column 4 content"
   objLst.SubItems(4) = "Column 5 content"
   objLst.SubItems(5) = "Column 6 content"
   
   objLst.SubItems(6) = "7 the Column content"
   
   'Bolding 7 the column
   objLst.ListSubItems(6).Bold = True
   
   objLst.SubItems(7) = "Column 8 content"
   objLst.SubItems(8) = "Column 9 content"

'=========================

;-)
Shiju
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 53

Expert Comment

by:Dhaest
ID: 13619516
The only solution, except by setting all the subitems (like shijusn demonstrated) is to subclass your listview.
Examples:
http://vbnet.mvps.org/index.html?code/comctl/lvbackground.htm
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20360935.html
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 13619518
0
 
LVL 4

Expert Comment

by:rdwillett
ID: 13619884
If you are allowing nulls in column 7 then you must do two things.  First make all none null numbers bold in Column 7 (Subitems6)

Add this Sub to the form in which your listview resides and call this sub after loading data into listview: ( Change YourListViewName to Your List View Name)

Private Sub MakeColumn7Bold()
    On Error Resume Next
    Dim x As Integer
    For x = 0 To ListView1.ListItems.Count - 1
       YourListViewName.ListItems(x).ListSubItems(6).Bold = True
    Next x
End Sub


If u are allowing nulls then modify the following sub in LabelEdit.cls


Public Sub SetText()
    On Error Resume Next
    Dim Distri As Double, MarkUp As Double, Exchange As Double, USD As Double, Reseller As Double, Sell As Double

    objItem.Text = txtEdit.Text
    If objItem.Text <> CurText Then
        objItem.Text = txtEdit.Text
        objItem.ForeColor = vbRed
        'Added all of this to check which column was editted
        If CurCol = 4 Or CurCol = 5 Or CurCol = 6 Then
            If Val(ltvListView.ListItems(CurInd).SubItems(3)) = 0 _
            Or Val(ltvListView.ListItems(CurInd).SubItems(4)) = 0 _
            Or Val(ltvListView.ListItems(CurInd).SubItems(5)) = 0 _
            Then
                ltvListView.ListItems(CurInd).SubItems(3) = 0
                ltvListView.ListItems(CurInd).SubItems(4) = 0
                ltvListView.ListItems(CurInd).SubItems(5) = 0
                ltvListView.ListItems(CurInd).SubItems(6) = 0
                ltvListView.ListItems(CurInd).SubItems(7) = 0
                ltvListView.ListItems(CurInd).ListSubItems(6).Bold = True  'Add this
                'ltvListView.ListItems(CurInd).SubItems(8) = 0
                txtEdit.Visible = False
                Exit Sub
            Else
                USD = ltvListView.ListItems(CurInd).SubItems(3)
                Exchange = ltvListView.ListItems(CurInd).SubItems(4)
                MarkUp = ltvListView.ListItems(CurInd).SubItems(5)
                Distri = Format$(USD * Exchange / MarkUp, "#,##0")
                Reseller = Format$(Distri / 0.95, "#,##0")
                Sell = Format$(Reseller / 0.7, "#,##0")
                ltvListView.ListItems(CurInd).SubItems(6) = Distri
                ltvListView.ListItems(CurInd).SubItems(7) = Reseller
                ltvListView.ListItems(CurInd).SubItems(8) = Sell
                'Only do this if you want the calculated values to turn red or blue or whatever
                ltvListView.ListItems(CurInd).ListSubItems(6).ForeColor = vbBlue
                ltvListView.ListItems(CurInd).ListSubItems(7).ForeColor = vbBlue
                ltvListView.ListItems(CurInd).ListSubItems(6).Bold = True   'Add this
                ltvListView.ListItems(CurInd).ListSubItems(8).ForeColor = vbBlue
                txtEdit.Visible = False
            End If
        End If
        txtEdit.Visible = False
    End If
End Sub

Make sure that the On Error Resume Next is present in the LabelEdit.cls sub
0
 
LVL 4

Accepted Solution

by:
rdwillett earned 2000 total points
ID: 13619913
Sorry the first sub should have been:

Private Sub MakeColumn7Bold()
    On Error Resume Next
    Dim x As Integer
    For x = 1 To ListView1.ListItems.Count
        ListView2.ListItems(x).ListSubItems(6).Bold = True
    Next x
End Sub

Got combo boxes on my mind.  You can include this routine in your data load event immediately after loading data if you wish.
0
 
LVL 4

Expert Comment

by:rdwillett
ID: 13619936
Why can't u install vb sp6?
Is it giving u the message: Can not find any registered Visual Studio products or something similar?
0
 

Author Comment

by:aarontham
ID: 13627464
Dear rdwillett,

the msg like below.

16 bit windows subsystem

C:\winnt\system32\autoexec.nt. The system file is not suitable for running MS_DOS and Microsoft Windows applacations Choose 'Clase' to terminate the application.
0
 
LVL 4

Expert Comment

by:rdwillett
ID: 13628010
One of the following files is missing or corrupt.

     Config.nt
     Autoexec.nt
     Command.com

Search for these files on your computer and find if any are missing.  You can go to another computer with the same operating system and copy these files to your computer.  Note the same operating system.

For Windows 2000: %Systemroot% = C:\WINNT   (place files here)
Windows XP: %Systemroot% = C:\Windows         ( place file here)

After placing the files in the appropriate directory try running your sp6 patch.

Note you should rename old files before copying new files to insure copy works.
0
 

Author Comment

by:aarontham
ID: 13628311
Dear rdwillett,

After copy Autoexec.nt  over i can install SP6. after install SP6 and i try your listview code it still don't work.
0
 
LVL 4

Expert Comment

by:rdwillett
ID: 13628797
Mine works. Something has to be different. Will work on it tommorrow with new approach and see if i can create a simpler function for null checking.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month14 days, 6 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question