|
what is this solution mean ??
|
|
|
|
|
It simply converted the URLs given to you by Coding C#, into links, to make things easier for other readers.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
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?
|
|
|
|
|
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.
|
|
|
|
|
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!!
|
|
|
|
|
Hmm.. I dont see any :
item.Text = "MyTitle";
or something like that.
I see only SubItems.
|
|
|
|
|
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.
|
|
|
|
|
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);
|
|
|
|
|
hi....i m working in forms i want to show a form for 3 or 4 seconds and then start showing onther form for this i need to user a timer which display first form for 4 seconds then transfer control to other form....how can i user this timer???? i know sSystem.Timers.Timer is available but how to use it?????????????????
|
|
|
|
|
Your best bet, if you ever want to be a programmer in any shape or fashion, is to read the MSDN to find out how to use a timer. That's if you can't work it out, it's kind of self documenting. Then, if you can't work it out ( which would be odd, as it's very simple and the examples very clear ), post your code here so we can help you.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
i have used
System.Timers.Timer t=new System.Timers.Timer();
t.start();
t.end();
but now,,,,i dont know where to set the time interval 4 seconds in these 2 methods??????
|
|
|
|
|
This should help you
http://www.c-sharpcorner.com/UploadFile/mahesh/WorkingwithTimerControlinCSharp11302005054911AM/WorkingwithTimerControlinCSharp.aspx
http://www.csharphelp.com/archives/archive90.html
Coding C#
www.excitetemplate.com
|
|
|
|
|
|
Hi,
MahaKh wrote: .i m working in forms
if it is WinForms you are using, then System.Windows.Forms.Timer would be easier for your needs, as it ticks on the GUI thread.
For all timers: there is initialization including starting the timer, and there is event handling (a Tick event or Elapsed event depending on timer).
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.
|
|
|
|
|
Wow, it still amazes me that people have never heard of Google!
Is this really that hard to figure out?
Google: C# timer[^]
Using Google, you get quicker response, more examples, and plenty of choices. IMHO, many questions that get posted should be looked for on google first.
_____________
Joe
|
|
|
|
|
Opps, dup post.
|
|
|
|
|
public Hashtable FetchArray(ref OdbcDataReader reader)
{
int counter = 0;
int integer = reader.FieldCount;
Hashtable hashtable = new Hashtable();
if (reader.Read())
{
for (int i = 0; i <= integer+1; i++)
{
hashtable.Add(reader.GetName(i), reader.GetValue(i));
}
counter++;
}
return hashtable;
}
Im using MySQL Connector/ODBC 5.1
|
|
|
|
|
Haven't tried it, but...
Frozzeg wrote: int integer = reader.FieldCount;
...
for (int i = 0; i <= integer+1; i++)
Isn't that reading FieldCount + 1 entries?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
I don't think so. It attempts to read FieldCount+2 entries.
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.
|
|
|
|
|
My bad. Missed the "=" in "<=" - I blame Monday morning disease!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Frozzeg wrote: for (int i = 0; i <= integer+1; i++)
It should be
for (int i = 0; i<integer; i++)
DbDataReader columns store collection is ZERO based.
Life is a stage and we are all actors!
|
|
|
|
|
|
It has to, because that fixes your ( very obvious ) bug. How about you learn to use the debugger, then examine the code to work out exactly what is wrong ? You can then ask here and you'll get a real answer, because you will ask an intelligent question
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
In the first message, I pointed to a code string with an error
|
|
|
|
|
Yes that is true, you get expection when accsess an index that doesn't exsist.
If you have 3 indexes.
for (int i=0; i<=index+1;i++)
first part: i<=index. when you count 3, loop will do extra loop because of '<=' will do extra loop till i gets to 3. but it is zero based index and if i gets to 3, there are 4 indexes already, while reader have only 3. The second part is +1. Lose it. if you wan't to keep <= then use instead index+1 use index-1
edit: Also all exceptions comes with description, probably yours came with "Index out of boundary". When you wan't to know what is wrong,sometimes it is not enough the place and witch expection. All exceptions comes with a message
Frozzeg wrote: In the first message, I pointed to a code string with an error
You only pointed where AccessViolationException happens
edit 2: Copy paste from MSDN
Remarks
An access violation occurs in unmanaged or unsafe code when the code attempts to read or write to memory that has not been allocated, or to which it does not have access. This usually occurs because a pointer has a bad value. Not all reads or writes through bad pointers lead to access violations, so an access violation usually indicates that several reads or writes have occurred through bad pointers, and that memory might be corrupted. Thus, access violations almost always indicate serious programming errors. In the .NET Framework version 2.0, an AccessViolationException clearly identifies these serious errors.
In programs consisting entirely of verifiable managed code, all references are either valid or null, and access violations are impossible. An AccessViolationException occurs only when verifiable managed code interacts with unmanaged code or with unsafe managed code.
Version Information
This exception is new in the .NET Framework version 2.0. In earlier versions of the .NET Framework, an access violation in unmanaged code or unsafe managed code is represented by a NullReferenceException in managed code. A NullReferenceException is also thrown when a null reference is dereferenced in verifiable managed code, an occurrence that does not involve data corruption, and there is no way to distinguish between the two situations in versions 1.0 or 1.1.
modified on Monday, August 17, 2009 5:09 AM
|
|
|
|