[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1755
  • Last Modified:

Listview bold

Hi,

I have a 9 column listview, How do make column 7 whole column bold.
0
aarontham
Asked:
aarontham
  • 5
  • 2
  • 2
  • +2
1 Solution
 
DabasCommented:
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
 
Shiju SasidharanAssoc Project ManagerCommented:
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
 
Shiju SasidharanAssoc Project ManagerCommented:
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
DhaestCommented:
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
 
DhaestCommented:
0
 
rdwillettCommented:
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
 
rdwillettCommented:
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
 
rdwillettCommented:
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
 
aaronthamAuthor Commented:
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
 
rdwillettCommented:
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
 
aaronthamAuthor Commented:
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
 
rdwillettCommented:
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now