Thanks Chris,
I had thought about doing something similar to your suggestion but it would
be a bit tough because the dataset is populated from a system wide search
class I had created.
Instead I did:
System.Windows.Forms.ListViewItem []ls = new
ListViewItem[ds.Tables[0].Rows.Count];
ls[0] = new ListViewItem();
ls[0].Tag = ds.Tables[0].Rows[0].ItemArray[0].ToString();
ls[0].Text = "Current";
for(int i=1; i<ds.Tables[0].Rows.Count; i++)
{
ls[i] = new ListViewItem();
ls[i].Tag = ds1.Tables[0].Rows[i].ItemArray[0].ToString();
ls[i].Text = ds1.Tables[0].Rows[i].ItemArray[1].ToString();
}
this.lstBox.DataSource = ls;
this.lstBox.DisplayMember = "Text";
this.lstBox.ValueMember = "Tag";
"Chris Ballard" <Ch**********@discussions.microsoft.com> wrote in message
news:79**********************************@microsof t.com...
John,
Because the list is data bound, the selected item has to be within the
data itself. And yes, I suspect that the problem with changing the dataset is
that the column in question should be a date.
If you are getting the dataset via a SQL select command, you could use a
query such as:
SELECT 0 AS ID, 'Latest Revision' AS Date
UNION
SELECT id, CONVERT(varchar(30),thedate) FROM mytable
assuming that there are no items in the table with ID = 0.
Chris.
"John Smith" wrote:
Hey folks,
I've got a combobox (DropDown List) in a windows form application which
is bound to a DataSet.
It's value is set to a numeric ID. It's visible text is set to a date.
I need to make it so that the first item shows the words "Most Recent"
instead of the date.
I've tried setting the SelectedItem, Text, and SelectedText of the list
box to "Most Recent", when the SelectedIndex changes to 0, but nothing
happens. I also tried changing it in the dataset before (and after) it is bound,
by doing
ds.Tables[0].Rows[0].ItemArray[1] = "Most Recent", but that does nothing
either. It always displays the date instead. I think it may be related
to the fact that the ValueType in the DataSet is a DateTime.
Any idea how to accomplish this?