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. C#
  4. ListView not populatng

ListView not populatng

Scheduled Pinned Locked Moved C#
csharplinqgraphicssales
6 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
    kanchoette
    wrote on last edited by
    #1

    I have a main form 'customerForm' with a button which creates a child window 'customerPrintForm' containing a listView. So:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;

    namespace DebtManagement
    {
    public partial class DiaryPrintForm : Form
    {
    private ListViewSortManager m_sortMgr;
    private System.Windows.Forms.BindingManagerBase customerBinding;
    private Font colorFont;
    private int indexCounter = 0;
    private customerForm customerForm;
    private int customerIndex;

        public DiaryPrintForm(customerForm customerForm, int customerIndex)
        {
            InitializeComponent();
            this.customerForm = customerForm;
            this.customerIndex = customerIndex;
            customerDataSet.Merge(customerForm.customerDataSet);
            customerBinding = BindingContext\[customerDataSet, "customer"\];
            BindingContext\[customerDataSet, "customer"\].Position = customerIndex;
            PopulateDiaryListView();
        }
    
        private void DiaryPrintForm\_Load(object sender, System.EventArgs e)
        {
            colorFont = new Font("Wingdings", 12f, GraphicsUnit.Point);
        }
    
        private void DiaryPrintForm\_Closed(object sender, System.EventArgs e)
        {
            colorFont = null;
        }
    
        private void PopulateDiaryListView()
        {
            DateTime date = new DateTime(1970, 1, 1);
            string fileToShow = "";
            diaryListView.Items.Clear();
            
            if (customerBinding.Count > 0)
            {
                foreach (customerDataSet.DiaryRow row in customerDataSet.customer.DefaultView\[customerBinding.Position\].Row.GetChildRows("customerDiary"))
                {
                    if (row.RowState != DataRowState.Deleted)
                    {
                        
                        customerDataSet.UsersRow user = row.UsersRowByUsersDiary;
                        ListViewItem item = new ListViewItem();
                        if (row.IsFilenameNull() != true)
                        {
                            item.ImageIndex = 0;
                        }
    
                        if (row.DiaryActionID.ToString() == "33")
                        {
                            if (row.DiaryDate.CompareTo(date) == 1)
                            {
    
    L 1 Reply Last reply
    0
    • K kanchoette

      I have a main form 'customerForm' with a button which creates a child window 'customerPrintForm' containing a listView. So:

      using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.Data;
      using System.Drawing;
      using System.Linq;
      using System.Text;
      using System.Windows.Forms;

      namespace DebtManagement
      {
      public partial class DiaryPrintForm : Form
      {
      private ListViewSortManager m_sortMgr;
      private System.Windows.Forms.BindingManagerBase customerBinding;
      private Font colorFont;
      private int indexCounter = 0;
      private customerForm customerForm;
      private int customerIndex;

          public DiaryPrintForm(customerForm customerForm, int customerIndex)
          {
              InitializeComponent();
              this.customerForm = customerForm;
              this.customerIndex = customerIndex;
              customerDataSet.Merge(customerForm.customerDataSet);
              customerBinding = BindingContext\[customerDataSet, "customer"\];
              BindingContext\[customerDataSet, "customer"\].Position = customerIndex;
              PopulateDiaryListView();
          }
      
          private void DiaryPrintForm\_Load(object sender, System.EventArgs e)
          {
              colorFont = new Font("Wingdings", 12f, GraphicsUnit.Point);
          }
      
          private void DiaryPrintForm\_Closed(object sender, System.EventArgs e)
          {
              colorFont = null;
          }
      
          private void PopulateDiaryListView()
          {
              DateTime date = new DateTime(1970, 1, 1);
              string fileToShow = "";
              diaryListView.Items.Clear();
              
              if (customerBinding.Count > 0)
              {
                  foreach (customerDataSet.DiaryRow row in customerDataSet.customer.DefaultView\[customerBinding.Position\].Row.GetChildRows("customerDiary"))
                  {
                      if (row.RowState != DataRowState.Deleted)
                      {
                          
                          customerDataSet.UsersRow user = row.UsersRowByUsersDiary;
                          ListViewItem item = new ListViewItem();
                          if (row.IsFilenameNull() != true)
                          {
                              item.ImageIndex = 0;
                          }
      
                          if (row.DiaryActionID.ToString() == "33")
                          {
                              if (row.DiaryDate.CompareTo(date) == 1)
                              {
      
      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      look at colorFont :)

      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

        look at colorFont :)

        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
        kanchoette
        wrote on last edited by
        #3

        Well, I removed all colorFont references, together with the associated listView column, and this has not improved matters. I still have a 'blank' listView. This is driving me nuts!!:confused:

        L 1 Reply Last reply
        0
        • K kanchoette

          Well, I removed all colorFont references, together with the associated listView column, and this has not improved matters. I still have a 'blank' listView. This is driving me nuts!!:confused:

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Hmm.. I dont see any : item.Text = "MyTitle"; or something like that. I see only SubItems.

          K 1 Reply Last reply
          0
          • L Lost User

            Hmm.. I dont see any : item.Text = "MyTitle"; or something like that. I see only SubItems.

            K Offline
            K Offline
            kanchoette
            wrote on last edited by
            #5

            Sorry, but I don't understand your reply. I'm using a) Create new listViewItem b) add subitems to listViewItem c) Add listViewItem to listview model. Which I use successfully elsewhere in my project. I am not sure what your 'item.Text = "MyTitle";' pertains to.

            L 1 Reply Last reply
            0
            • K kanchoette

              Sorry, but I don't understand your reply. I'm using a) Create new listViewItem b) add subitems to listViewItem c) Add listViewItem to listview model. Which I use successfully elsewhere in my project. I am not sure what your 'item.Text = "MyTitle";' pertains to.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              I think, if you add an item to listView, then you must also add a text to that item. If you don't add a text to that item, then it will shows nothing. ListViewItem item = new ListViewItem(); item.Text = "ABC"; listView.Items.Add(item);

              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