there is a different and better way to achieve a numbered list: ListBox (and ComboBox) support
"OwnerDraw" mode, which means you paint the items yourself in any way you like, instead
of their string value being shown as is. So what you could do is add a DrawItem handler
that does a Graphics.DrawString(itemIndex.ToString()+". "+item.ToString());
Doing this will automatically show the text with its number, whatever happens to the list.
You would have to get the itemIndex from DrawItemEventArgs.Index, and item from
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
am trying to develop one aplication to read a particular node in an xml file. but somewhere i goes wrong and not working.......
plz help me to find out the error.....
In the following xml file i want to find out the last name.
This is the xml
<?xml version="1.0" encoding="UTF-8" ?>
and the code is --------
FileStream fs = new FileStream("D:\\Myfolder\\gender.xml", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
XmlNodeList xmlnode = xmldoc.GetElementsByTagName("name");
for (int a = 0; a < xmlnode.Count; a++)
if (xmlnode[a].Attributes.Value == "gender")
// match your attributes
String firstNameValue = reader.ReadElementString("gender");
Lblmsg.Text=" FirstName: "+firstNameValue;
I tried this one also=======
XmlTextReader reader = new XmlTextReader ("D:\\Myfolder\\gender.xml");
XmlDocument xmldoc = new XmlDocument();
XmlTextReader reader = new XmlTextReader ("C:\\gender.xml");
String firstNameValue = reader.ReadElementString("firstname");
String lastNameValue = reader.ReadElementString("lastname");
Lblmsg.Text=" FirstName: "+firstNameValue + " LastName: " + lastNameValue;
catch (Exception err )
Lblmsg.Text="Error: " + err.ToString();
-- modified at 23:25 Wednesday 12th September, 2007
Is there a way to save the username and password when user login.
I will access computer name \\ROBO then username and password form pop up.Think on computer neighborhood. When that user input his/her username and password. It will save on temporary file. Is it possible? How to do that? Much better if you can give a link or an existing application that can be downloaded (3rd party).
Thanks in advance,
I just want to
Hi I'm posting a new question in case Malcolm doesn't read my reply in time.
Basically what is wrong with this code? I want to automatically check the checklistbox items depending on if the items match the employees TechnicalSkillsID in the database table. Malcolm gave me a web form example which was a great response except I forgot to tell him I was using a winform.
can you help at all?
int i;<br />
for (i = 0; i <= (techSkillsCheckListBox2.Items.Count - 1); i++)<br />
// SqlDataReader MyDataReader = adoCmd.ExecuteReader(CommandBehavior.CloseConnection);<br />while (adoDR.Read())<br />
sql = "Select em.TechnicalSkillsID,t.ProgLanguagesDatabase from EmpSkills em,TechnicalSkills t where EmployeeID = '" + FirstnameText.Text + "' and em.TechnicalSkillsID = t.TechnicalSkillsID";<br />
//populate a datatable with the result set<br />
DataRow rows = dataSet1.TechnicalSkills.Select();<br />
foreach (DataRow row in rows)<br />
string techID = row["TechnicalSkillsID"].ToString();<br />
techSkillsCheckListBox2.SetItemChecked(i, true);<br />
Of course, I just invented some variables, assume the Tag of the checkbox contains the key value, so you can look it up. The code you're presenting does a nested loop, and just sets each box to be checked, over and over again.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
Thanks but the part you are talking about that is wrong, is actually the part that is correct and gives the correct value. I got that off msdn. Yes I want to fill a list with items but as i said, I can't use listitems as I'm using a winform so I would like to know how I do that exactly. How do you check the items against the ID's against an empID in the database?
I'm not sure what you mean but i think I have filled the list already as you said as the items are there. I just need the ticked items to save as correct ID's in the database against a given employee. I would've used bits and pieces of msdn stuff so that might be why its messy. I didn't copy a whole paragraph of code, just a line here and there.
I am trying to draw a line on a bitmap. I have tried using System.Drawing.Graphics, however this apparently only works with forms. When I try the following code: System.Drawing.Graphics.DrawLine(drawerpen, lastpoint, currentpoint);
I get an error saying that I must create an object instance to use this. However, System.Drawing.Graphics has no constructors, so I cannot create an instance such as: System.Drawing.Graphics lineDrawer = new System.Drawing.Graphics();
How can I draw lines on a bitmap?