Click here to Skip to main content
15,891,513 members
Home / Discussions / C#
   

C#

 
GeneralRe: threadsafe / static, general utilities Pin
pkellner6-Feb-05 12:19
pkellner6-Feb-05 12:19 
QuestionDifferent ways to persist/share temporary data across classes in a multi-tier WinForm Application? Pin
DaMagicMaster5-Feb-05 20:07
DaMagicMaster5-Feb-05 20:07 
AnswerRe: Different ways to persist/share temporary data across classes in a multi-tier WinForm Application? Pin
Heath Stewart6-Feb-05 6:42
protectorHeath Stewart6-Feb-05 6:42 
AnswerRe: Different ways to persist/share temporary data across classes in a multi-tier WinForm Application? Pin
DaMagicMaster6-Feb-05 16:39
DaMagicMaster6-Feb-05 16:39 
GeneralRe: Different ways to persist/share temporary data across classes in a multi-tier WinForm Application? Pin
Heath Stewart7-Feb-05 6:35
protectorHeath Stewart7-Feb-05 6:35 
GeneralRe: Different ways to persist/share temporary data across classes in a multi-tier WinForm Application? Pin
DaMagicMaster7-Feb-05 12:50
DaMagicMaster7-Feb-05 12:50 
GeneralRe: Different ways to persist/share temporary data across classes in a multi-tier WinForm Application? Pin
Heath Stewart7-Feb-05 15:39
protectorHeath Stewart7-Feb-05 15:39 
GeneralDelete XmlNode Pin
John L. DeVito5-Feb-05 19:31
professionalJohn L. DeVito5-Feb-05 19:31 
ok so I've done some thinking about this and here's what I've come up with. The XML file followed by Psuedo code followed by the code.

XML FIle:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<categories>
<category>Operating System</category>
<category>Productivity</category>
<category>Entertainment</category>
<category>Games</category>
<category>Misc.</category>
</categories>
<disk_numbers>
<disk>001</disk>
<disk>002</disk>
<disk>003</disk>
</disk_numbers>
</configuration>

Psuedo Code:

start in parent node "categories"
for each child node it has named "category"
check if innerText is equal to the selected item in the combo box

if it is
remove the child node
if it isn't
go to the next child node

during one pass through the child nodes this can never fail since the combo box item wouldn't be
listed if it wasn't in the file

Code:

private void mainToolbarRemoveCategoryButton_ItemClick(object sender,
DevExpress.XtraBars.ItemClickEventArgs e)
{
XmlNode parentNode = configDoc.SelectSingleNode("/configuration/categories");

if(MessageBox.Show("Are you sure?", "Katalog", MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation) == DialogResult.No)
{
return;
}
else
{
foreach(XmlNode n in parentNode)
{
if(n.InnerText.ToString() == programCategoryComboBoxEdit.SelectedItem.ToString())
{
try
{
parentNode = n.ParentNode;
parentNode.RemoveChild(n);
configDoc.Save("katalog.config");
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
}

So hopefully it's obvious what I'm trying to do, I guess the foreach loop is where the issue is, is this how I would traverse each child node?

thanks!

GeneralRe: Delete XmlNode Pin
Stefan Troschuetz5-Feb-05 21:07
Stefan Troschuetz5-Feb-05 21:07 
GeneralRe: Delete XmlNode Pin
Heath Stewart6-Feb-05 6:33
protectorHeath Stewart6-Feb-05 6:33 
GeneralRe: Delete XmlNode Pin
John L. DeVito8-Feb-05 12:01
professionalJohn L. DeVito8-Feb-05 12:01 
Questionhow to make what SelectionIndent does in tabs Pin
ektoras5-Feb-05 13:46
ektoras5-Feb-05 13:46 
AnswerRe: how to make what SelectionIndent does in tabs Pin
Heath Stewart6-Feb-05 6:29
protectorHeath Stewart6-Feb-05 6:29 
GeneralRe: how to make what SelectionIndent does in tabs Pin
ektoras14-Feb-05 0:59
ektoras14-Feb-05 0:59 
GeneralDifferent font colors in textbox Pin
MG00c2x5-Feb-05 11:47
MG00c2x5-Feb-05 11:47 
GeneralRe: Different font colors in textbox Pin
mav.northwind6-Feb-05 3:56
mav.northwind6-Feb-05 3:56 
GeneralRe: Different font colors in textbox Pin
sugunet7-Feb-05 1:38
sugunet7-Feb-05 1:38 
Generalnew line in string Pin
Majid Shahabfar5-Feb-05 10:29
Majid Shahabfar5-Feb-05 10:29 
GeneralRe: new line in string Pin
Beringer5-Feb-05 11:58
Beringer5-Feb-05 11:58 
GeneralRe: new line in string Pin
MG00c2x5-Feb-05 12:03
MG00c2x5-Feb-05 12:03 
GeneralRe: new line in string Pin
S. Senthil Kumar5-Feb-05 16:06
S. Senthil Kumar5-Feb-05 16:06 
GeneralRe: new line in string Pin
Majid Shahabfar6-Feb-05 6:07
Majid Shahabfar6-Feb-05 6:07 
GeneralRe: new line in string Pin
Jon Sagara5-Feb-05 18:52
Jon Sagara5-Feb-05 18:52 
GeneralRe: new line in string Pin
sugunet6-Feb-05 0:55
sugunet6-Feb-05 0:55 
GeneralRe: new line in string Pin
Majid Shahabfar6-Feb-05 6:05
Majid Shahabfar6-Feb-05 6:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.