|
Please don't cross post questions.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I was not sure, whether my question comes under .net framework or c#. Thats why i posted it under both the topics.
|
|
|
|
|
Hii
i am working with windows application and i want to change the datagridview cell value's color to red color if that cell value is less than the current value which comes from a datatable or datagridview cell value's color to blue color if that cell value is greater than the current value which comes from a datatable.
plzz help me and send me code for the same
thanks in advance..
Nitin
|
|
|
|
|
this should help you
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.cellendedit.aspx
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview_events.aspx
|
|
|
|
|
Clickety Police - 1[^]
Clickety Police - 2[^]
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.”
|
|
|
|
|
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
|
|
|
|