Hi, i am trying to use a list view to display a list of passed and failed items but the images are not always displaying. Sometimes the images will display fine and others they just will not appear.
I've created an ImageList and added the images to it by:
imageList1.Images.Add(Bitmap.FromFile(Application. StartupPath + "\\Images\\image.gif"));
I set the small and large Image list properties on the ListView to the newly created image list. I tried swapping these around i.e. only using smallimagelist etc. but still have the same issue. I can not seem to figure out what i am doing wrong. I've tried this both in release and debug mode(however, I did have some issues in release mode which I have now fixed).
Anyone be able to help me with this issue?
Thanks in advance,
Piercy
edit: Heres and image to see what i mean.. These were taken within 5 minutes of each other with no code changes between. just a note, the names are all demo data so dont worry about that. 3 5713
B U M P
Im still extremly stuck on this dont have a clue what the problem is.
I tried this: (as suggested by Francisco25) -
LockWindowUpdate(this.Handle); //Lock the windows main client for refreshing
-
-
imageList1.Images.Add(Bitmap.FromFile(Application.StartupPath + "\\Images\\image.gif"));
-
-
LockWindowUpdate(IntPtr.Zero); //Unlock all the locked windows
-
-
-
Application.DoEvents(); //Refresh all the events in the queu
-
But it didnt work.
im not sure what other code i can show you as all im really doing is populating the box from a database and displaying some text on the page. Heres the part where i add to the list view. It gets some information from a already populated datagrid then select the correct message and receipiants from the database and populate accordingly. (and yes i know receipiants is not spelled like receipitants but i dont want to have to change the database...) also, the refreshes were to try help fix the problem. Ill remove them eventually..: -
private void dataGrid1_CurrentCellChanged(object sender, System.EventArgs e)
-
{
-
-
System.Drawing.Point pt = dataGrid1.PointToClient(Cursor.Position);
-
listView1.Items.Clear();
-
dg1val = dataGrid1[dataGrid1.CurrentCell.RowNumber, 0].ToString();
-
dg1val = dg1val.Replace(":","");
-
dg1val = dg1val.Replace("/","");
-
dg1val = dg1val.Replace(" ","");
-
this.sqlSelectCommand2.CommandText = "SELECT PupilID, Receipitant,ErrorID, Display, errormess FROM Receipitants INNER JOIN ErrorID ON Receipitants.ErrorID = ErrorID.ID WHERE (Receipitants.MsgID =" + this.dg1val.ToString() + ") ORDER BY Receipitants.ErrorID";
-
-
-
try
-
{
-
-
ds1.Tables["Receipitants"].Clear();
-
}
-
catch { }
-
try
-
{
-
this.sqlDataAdapter2.Fill(ds1, "Receipitants");
-
}
-
catch (System.Exception ex)
-
{
-
MessageBox.Show(ex.Message.ToString());
-
}
-
-
-
DataTable temp = this.ds.Tables["Message"];
-
foreach (DataRow row in ds1.Tables["Receipitants"].Rows)
-
{
-
if (row.ItemArray[1].ToString() != null)
-
{
-
if (row.ItemArray[1].ToString().Length > 0)
-
{
-
ListViewItem lvi = new ListViewItem(new string[] { row.ItemArray[3].ToString() + " (" + row.ItemArray[1].ToString() + ")"},0);
-
lvi.ToolTipText = row.ItemArray[4].ToString();
-
listView1.Items.Add(lvi);
-
-
}
-
else
-
{
-
ListViewItem lvi = new ListViewItem(row.ItemArray[3].ToString());
-
lvi.ToolTipText = row.ItemArray[4].ToString();
-
lvi.ImageIndex = 1;
-
listView1.Items.Add(lvi);
-
}
-
}
-
else
-
{
-
ListViewItem lvi = new ListViewItem(row.ItemArray[3].ToString());
-
lvi.ToolTipText = row.ItemArray[4].ToString();
-
lvi.ImageIndex = 1;
-
listView1.Items.Add(lvi);
-
}
-
}
-
string command = "SELECT Subject,Body FROM [Message] WHERE MsgID=@id";
-
string message = null;
-
string subject = null;
-
try
-
{
-
conn.Open();
-
SqlCommand cmd = new SqlCommand(command, conn);
-
cmd.Parameters.Add("@id", SqlDbType.BigInt).Value = dg1val.ToString();
-
SqlDataReader myReader = cmd.ExecuteReader();
-
while (myReader.Read())
-
{
-
subject = myReader[0].ToString();
-
message = myReader[1].ToString();
-
}
-
-
}
-
catch (System.Exception ex)
-
{
-
MessageBox.Show(this, "Database Error: " + ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
-
}
-
finally
-
{
-
conn.Close();
-
}
-
this.richTextBox1.Text = message;
-
this.richTextBox2.Text = subject;
-
listView1.Refresh();
-
Size temp1 = listView1.TileSize;
-
temp1.Width = ((listView1.Size.Width - System.Windows.Forms.SystemInformation.VerticalScrollBarWidth)-(3*16)) / 3;
-
listView1.TileSize = temp1;
-
listView1.Refresh();
-
-
this.Refresh();
-
}
-
Thanks again,
Piercy
Ok, I think i've solved it... Found this post: http://rikkus.info/workaround-to-lis...ng-images.html
And after moving enablevisualstyle very slightly it seems to be working. Im not definate this is the solution because my problems intermitant but ive tested it a good 30 times now and it seems fine. If i have any more problems related to this ill post back. Thought id post this here so if anyones searching for the solution they find this.
Thanks,
Piercy
I have an experience using Ajax, that I use the tab extendion. I use an image button that the name is conflict with others, but the compiler cannot detected it and the image is not displayed properly.
Regards,
Man Pak Hong
manpahong@hotmail.com
Hi, i am trying to use a list view to display a list of passed and failed items but the images are not always displaying. Sometimes the images will display fine and others they just will not appear.
I've created an ImageList and added the images to it by:
imageList1.Images.Add(Bitmap.FromFile(Application. StartupPath + "\\Images\\image.gif"));
I set the small and large Image list properties on the ListView to the newly created image list. I tried swapping these around i.e. only using smallimagelist etc. but still have the same issue. I can not seem to figure out what i am doing wrong. I've tried this both in release and debug mode(however, I did have some issues in release mode which I have now fixed).
Anyone be able to help me with this issue?
Thanks in advance,
Piercy
edit: Heres and image to see what i mean.. These were taken within 5 minutes of each other with no code changes between. just a note, the names are all demo data so dont worry about that. Sign in to post your reply or Sign up for a free account.
Similar topics
by: tommazzo |
last post by:
I'm currently writing a photo album sotware in C#.
I'm using a ListView component to diaplay thumbnail previews of the photos
and want to give the user the possibility to rearrange the photos via a...
|
by: Anushya devi |
last post by:
Hi All
I used listview and tried to update it by using Addrange.
When the number of items is less, it works fine.. But I
need to update nearly 200,000 items and it hangs. Also i
need to add...
|
by: newbie |
last post by:
Hello,
I maybe asking too much in a single posting, but here it goes:
I building a windows form that mimic's the Outlook XP GUI. Its a three
pane form that will allow a user to view and edit...
|
by: |
last post by:
I think .NET 1.1.4322 ListView control has some bugs .I set ListView for
displaying details I set multiselect and fullrowselect to true.I set small
image list.When I compile it works well.But...
|
by: scoobydoo |
last post by:
hi,
I have a problem displaying icons at the right colour depthin a
ListView.
I've made an icon file, (using IconWorkshop 5), it has 3 icons within
it. A 32x32 32bpp XP style icon, a 32x32...
|
by: Pedro Fernandes |
last post by:
Hi all.
I have a problem when I do interop between .NET and VB6.
What happens is that the listview loses the tile view when my .NET form
is under VB6.
Does VB6 support this feature?
...
|
by: > Adrian |
last post by:
I have a form with two list views. In one list view the tile size is set to
the default value 0,0. I have not made any changes to these values. In the
other list view the tile size has values. I...
|
by: giddy |
last post by:
hi,
I have a listview on a form, the View is set to Tile. I also have an
image list tied to the *smallImageList property, i have one image in
the image list, its a png : 32X32
When i do...
|
by: Lord Zoltar |
last post by:
Hi,
I've got a list view that displays a series of images. I'd like to be
able to draw a divider across the list view to divide the images into
groups. Ideally, I'd have a group name, with a line...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |