|
|
Hi,
Two comments:
1. I suggest you have a look at String.StartsWith()
2. You might want to store the results of cachedPartNumbers[i].ToString() rather than calling
it all the time
|
|
|
|
|
Hi,
My code is looping through records and adding items to a listbox as below:
forloop
{
lstBox1.items.add("item1");
lstBox1.items.add("item2");
}
Question:
How can I change the colour of SOME of the items as they are being added?
Thanks
|
|
|
|
|
Hi,
there are two basic features you need:
- ListBoxes can contain items of any type, not just strings
- you can paint those items yourself (DrawMode OwnerDrawn, event DrawItem)
So the neat way to do this is define a little class (say MyItem) and let it hold a string and
some style field (maybe a Color). Add instances of that class to the ListBox, make it OwnerDrawn,
and provide a DrawItem handler according to your wishes.
As a shortcut, when I only need two variations (say black and red), I skip the MyItem stuff and
prefix the red items with a special character (say '~'), then in DrawItem check the first char,
and if a '~', choose Color.Red and drop the '~'.
|
|
|
|
|
Hi,
I am not a good c# developer so not sure how to do what you suggested.
Can you make it simpler or guide me through it further please?
Thanks
|
|
|
|
|
Sorry, no spoon feeding here. I gave you all the required keywords, let Google and MSDN provide you
with the details; and CodeProject holds thousands of interesting articles too.
PS: don't switch Controls, if ListBox is your first choice, stick with it. It is a very good performer.
|
|
|
|
|
|
Luc Pattyn wrote: Sorry, no spoon feeding here.
He may not get what he wants (maybe mashed peas, squash, etc)
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
For a start, the loop is incorrect. It'd probably be something like this
for(int i = 0; i<3; i++)
{
lstBox1.Items.Add("item" + i.ToString("N0"));
}
Also, the standard ListBox cannot do that on its own. You could paint it yourself if you have a good grasp of the Graphics object, or you could use the ListView. The loop would change to something like this
for(int i = 0; i<3; i++)
{
ListViewItem lvi = new ListViewItem("item" + i.ToString("N0"));
lvi.BackColor = Color.White;
ListView1.Items.Add(lvi);
}
|
|
|
|
|
Hi,
I am trying to use a listview to make this easier.
Do you know why I do not get Color in the intellisense please?
Thanks
|
|
|
|
|
Have you added
using System.Drawing;
to the top of the file?
|
|
|
|
|
|
Hi all,
Can anyone help...im trying to figure out a way to get the value to text of a node...the problem is that my query returns around 2000 rows...i want to make it that i must click on a node to get its subnodes...how will i go about doing this?
living life on the flip side
|
|
|
|
|
|
Hello,
I am working in my application with xml files and mdb file,I don't want user view these files I want to put them in the app assembly.
Thanks.
Dad
|
|
|
|
|
yes it works for xml files but I don't know if mdb will work or won't work.
1. add a classLibrary project in your solution,
2. add the xml files into your new classLibrary project.
accessing to xml:
System.Reflection.Assembly xx = System.Reflection.Assembly.Load("yourNewClassLibraryProjectName");
string ress = xx.GetManifestResourceNames();
and you will read with xmlSerializer.
I'm not sure if you can change dinamically that xml files or not... .
modified on Wednesday, July 16, 2008 8:23 AM
|
|
|
|
|
The only real purpose of including the mdb file in the assembly is to have an already structured template for database creation/editing. You would not be able to edit the files embedded into the assembly. If you want to 'obscure' what the user can and cannot see with regards to the actual database file, I would suggest that you give it a 'critical application important file' type name. Second I would suggest that you give it an abnormal database extension. Ex. For my RevCorp accounting software I wrote, I labeled the file: AppData.revdb. Their was a copy of the file stored in the assembly. When the file could not be found in the directory where it was run the database was created from the assembly.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios
Discounted or Free Software for Students:
DreamSpark - downloads.channel8.msdn.com
MSDN Academic Alliance - www.msdnaa.com
|
|
|
|
|
I have created a setup of a win project and i installed the project on client machine.now i update my project and create a new version of setup.
now on client machine it shuld be updated it self
i need your help
thanx
|
|
|
|
|
ali zaidi wrote: now on client machine it shuld be updated it self
Not unless you have written some code in your app to do it. Google for .net deployment, there are loads of articles showing the problems and pitfalls.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hi All,
Can anyone tell me wat im doing wrong...im trying to populate a treeview from sql with a foreach loop...my code is like this..
foreach (DataRow dr in dt.Tables)<br />
{<br />
<br />
}<br />
Please tell me wat im doing wrong?
living life on the flip side
|
|
|
|
|
if dt is a DataSet then dt.Tables is a collection of Table s, not DataRow s. If dt is a DataTable (as the name suggests) you want dt.Rows
|
|
|
|
|
thanks alot...works like a bomb...thanks to all
living life on the flip side
|
|
|
|
|
ok thanks for your help but now i have another question...im trying to add subchild nodes to childnodes... my code
ListItem lstItem = new ListItem();
foreach (DataRow row in dt.Rows)
{
TheNode13.Text = "";
lstItem.Value = row["ID"].ToString();
lstItem.Text = row["Name"].ToString();
TheNode13.Text = lstItem.Text;
TheNode13.Value = lstItem.Value;
TheNode12.Nodes.Add(TheNode13);
}
everytime i add them then it overwrites the subchildnode and add the same node twice...wat am i doing wrong?
living life on the flip side
|
|
|
|
|
You need to instantiate a new TreeNode each time.
|
|
|
|
|
try dt.Tables[0].Rows
rahul
|
|
|
|