Click here to Skip to main content
15,894,017 members
Home / Discussions / C#
   

C#

 
AnswerCross post: Being answered in .NET Framework section Pin
Pete O'Hanlon17-Aug-09 3:45
mvePete O'Hanlon17-Aug-09 3:45 
GeneralRe: Cross post: Being answered in .NET Framework section Pin
vidhyaravichandar17-Aug-09 15:23
vidhyaravichandar17-Aug-09 15:23 
QuestionHow to Change the datagridview cell value color Pin
Nitin K17-Aug-09 0:08
Nitin K17-Aug-09 0:08 
AnswerRe: How to Change the datagridview cell value color Pin
Coding C#17-Aug-09 0:27
Coding C#17-Aug-09 0:27 
GeneralRe: How to Change the datagridview cell value color Pin
Henry Minute17-Aug-09 0:50
Henry Minute17-Aug-09 0:50 
GeneralRe: How to Change the datagridview cell value color Pin
Nitin K17-Aug-09 1:23
Nitin K17-Aug-09 1:23 
GeneralRe: How to Change the datagridview cell value color Pin
Henry Minute17-Aug-09 1:31
Henry Minute17-Aug-09 1:31 
QuestionListView not populatng Pin
kanchoette16-Aug-09 23:33
kanchoette16-Aug-09 23:33 
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)
                            {
                                date = row.DiaryDate;
                                if (row["Filename"] != DBNull.Value)
                                {
                                    fileToShow = row.Filename.ToString();
                                }
                            }

                        }

                        item.SubItems.Add('\x6E'.ToString(), Color.FromArgb(row.DiaryActionRow.Color), diaryListView.BackColor, colorFont);
                        item.SubItems.Add(row.ManagerPriority.ToString());
                        item.SubItems.Add(row.UserPriority.ToString());
                        item.SubItems.Add(row.DiaryDate.ToString());
                        item.SubItems.Add(row.DiaryActionRow.Description);
                        item.SubItems.Add(row.Description);
                        item.SubItems.Add(row.IsDueDateNull() ? "" : row.DueDate.ToString());
                        item.SubItems.Add(row.Complete ? "Yes" : "No");
                        item.SubItems.Add(row.Charges.ToString("C"));
                        item.SubItems.Add(user.IsInitialsNull() ? "" : user.Initials);
                        item.SubItems.Add(row.IsNotesNull() ? "" : row.Notes);
                        item.SubItems.Add(row.ActionedByID.ToString());
                        item.SubItems.Add(row.Acknowledged.ToString());
                        item.SubItems.Add(row.IsLetterIDNull() ? "" : row.LetterID.ToString());
                        item.SubItems.Add(row.IsFilenameNull() ? "" : row.Filename.ToString());
                        item.SubItems.Add(user.IsFullNameNull() ? "" : user.FullName.ToString());

                        item.Tag = row;
                        diaryListView.Items.Add(item);
                        indexCounter++;
                    }

                    m_sortMgr = new ListViewSortManager(diaryListView,
                new Type[] {   
                               typeof(ListViewTextSort), 
                               typeof(ListViewTextSort), 
                               typeof(ListViewTextSort), 
                               typeof(ListViewTextSort), 
                               typeof(ListViewDateSort),
                               typeof(ListViewTextSort), 
                               typeof(ListViewTextSort),
                               typeof(ListViewDateSort),
                               typeof(ListViewTextSort),
                               typeof(ListViewDoubleSort),
                               typeof(ListViewTextSort)
                           },
                4, System.Windows.Forms.SortOrder.Descending);
                    
                }
                if (diaryListView.SelectedItems.Count == 0 && diaryListView.Items.Count > 0)
                {
                    diaryListView.Items[0].Selected = true;
                }
            }
        }
    }
}


However, the listView is not populating as expected (the rows are empty), although if I run my mouse over the expected date column a tooltip appears with the correct data.

Can anyone here see why this sould be please?
AnswerRe: ListView not populatng Pin
Luc Pattyn16-Aug-09 23:48
sitebuilderLuc Pattyn16-Aug-09 23:48 
GeneralRe: ListView not populatng Pin
kanchoette17-Aug-09 0:05
kanchoette17-Aug-09 0:05 
GeneralRe: ListView not populatng Pin
stancrm17-Aug-09 0:14
stancrm17-Aug-09 0:14 
GeneralRe: ListView not populatng Pin
kanchoette17-Aug-09 0:42
kanchoette17-Aug-09 0:42 
GeneralRe: ListView not populatng Pin
stancrm17-Aug-09 1:01
stancrm17-Aug-09 1:01 
Questiontimer Pin
MahaKh16-Aug-09 22:13
MahaKh16-Aug-09 22:13 
AnswerRe: timer Pin
Christian Graus16-Aug-09 22:29
protectorChristian Graus16-Aug-09 22:29 
GeneralRe: timer Pin
MahaKh16-Aug-09 22:37
MahaKh16-Aug-09 22:37 
GeneralRe: timer Pin
Coding C#16-Aug-09 22:44
Coding C#16-Aug-09 22:44 
GeneralRe: timer Pin
stancrm16-Aug-09 22:55
stancrm16-Aug-09 22:55 
AnswerRe: timer Pin
Luc Pattyn16-Aug-09 23:52
sitebuilderLuc Pattyn16-Aug-09 23:52 
AnswerRe: timer Pin
mustang8617-Aug-09 6:18
mustang8617-Aug-09 6:18 
AnswerRe: timer Pin
mustang8617-Aug-09 6:19
mustang8617-Aug-09 6:19 
QuestionAccessViolationException in OdbcDataReader Pin
Frozzeg16-Aug-09 22:04
Frozzeg16-Aug-09 22:04 
AnswerRe: AccessViolationException in OdbcDataReader Pin
OriginalGriff16-Aug-09 22:10
mveOriginalGriff16-Aug-09 22:10 
GeneralRe: AccessViolationException in OdbcDataReader Pin
Luc Pattyn16-Aug-09 23:54
sitebuilderLuc Pattyn16-Aug-09 23:54 
GeneralRe: AccessViolationException in OdbcDataReader Pin
OriginalGriff17-Aug-09 0:37
mveOriginalGriff17-Aug-09 0:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.