Click here to Skip to main content
15,912,329 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to control the controls of another form from current form Pin
quiteSmart11-Dec-06 2:23
quiteSmart11-Dec-06 2:23 
GeneralRe: How to control the controls of another form from current form Pin
Colin Angus Mackay11-Dec-06 7:32
Colin Angus Mackay11-Dec-06 7:32 
QuestionCombo Box question [modified] Pin
Muntyness10-Dec-06 23:05
Muntyness10-Dec-06 23:05 
AnswerRe: Combo Box question Pin
Martin#11-Dec-06 0:14
Martin#11-Dec-06 0:14 
GeneralRe: Combo Box question Pin
Muntyness11-Dec-06 0:43
Muntyness11-Dec-06 0:43 
AnswerRe: Combo Box question Pin
Martin#11-Dec-06 0:57
Martin#11-Dec-06 0:57 
GeneralRe: Combo Box question Pin
Muntyness11-Dec-06 1:16
Muntyness11-Dec-06 1:16 
GeneralRe: Combo Box question Pin
Muntyness11-Dec-06 6:26
Muntyness11-Dec-06 6:26 
Alrighty, Im here to bug you again.

So I took your framework and butchered it. (What can I say? I'm stupid Sigh | :sigh: )

public class fnt_ItemManager
    {
        public event EventHandler ArrayChanged;
        private Array _availableitems;

        public fnt_ItemManager()
        {
        }

        public Array AvailableItems
        {
            get
            {
                return _availableitems;
            }
            set
            {
                if (value != _availableitems)
                {
                    _availableitems = value;
                }
            }
        }

        public void update (String oldVal, String newVal)
        {
            ArrayList updating = new ArrayList();
            int i = 1;

            if (oldVal != null)
            {
                foreach (String st in _availableitems)
                {
                    if (newVal != st || newVal == "#NONE")
                    {
                        updating.Add(st);
                    }
                }

                if (oldVal != "#NONE")
                {
                    Boolean found = false;
                    while (i < updating.Count)
                    {
                        if (int.Parse((String)updating[i]) > int.Parse(oldVal))
                        {
                            updating.Insert(i, oldVal);
                            found = true;
                            break;
                        }
                        i++;
                    }
                    if (oldVal != null && found == false)
                    {
                        updating.Add(oldVal);
                    }
                }


                String[] rar = new String[updating.Count];
                i = 0;

                foreach (String st in updating)
                {
                    rar[i] = st;
                    i++;
                }

                _availableitems = rar;

                if (ArrayChanged != null)
                {
                    ArrayChanged(this, EventArgs.Empty);
                }
            }
        }
    }
}


And in the control that calls it:

private void cmb1_SelectedIndexChanged(object sender, EventArgs e)
{
    OldValue = Current;
    Current = cmb1.Text;

    if (OldValue != null && OldValue != Current)
    {
        ItemManager.update(OldValue, Current);
    }
}

void p_ItemManager_ArrayChanged(object sender, EventArgs e)
{
    cmb1.Items.Clear();

    foreach (String st in p_ItemManager.AvailableItems)
    {
        cmb1.Items.Add(st);
    }            
}


Now then, this actually works for the most part, however it's kinda iffy (seems to call all the handlers in the control class twice). Plus in the combo boxes, while the code see's the values that are in the boxes, people can't. So the code would see that the box contained "5", however I'm only seeing "". Kinda iffy once again.

Sooo, is this worth keeping, or should I just scrap it all and take up farming now? D'Oh! | :doh:

- Munty
GeneralRe: Combo Box question Pin
Martin#11-Dec-06 9:49
Martin#11-Dec-06 9:49 
GeneralRe: Combo Box question [modified] Pin
Muntyness12-Dec-06 3:19
Muntyness12-Dec-06 3:19 
GeneralRe: Combo Box question Pin
Martin#12-Dec-06 5:43
Martin#12-Dec-06 5:43 
GeneralRe: Combo Box question Pin
Muntyness12-Dec-06 8:48
Muntyness12-Dec-06 8:48 
QuestionRow Count Problem while reading file using OLDEB connection pls help me Pin
dhanabalanr10-Dec-06 23:00
dhanabalanr10-Dec-06 23:00 
Question"exception handling" Pin
ravikiranreddydharmannagari10-Dec-06 22:59
ravikiranreddydharmannagari10-Dec-06 22:59 
AnswerRe: "exception handling" Pin
Pete O'Hanlon10-Dec-06 23:03
mvePete O'Hanlon10-Dec-06 23:03 
Question'CopyLocal' - Reference Property Pin
AJ12310-Dec-06 22:57
AJ12310-Dec-06 22:57 
Questionhow to display windows form chart inside webpage? Pin
Velerena_sam10-Dec-06 22:56
Velerena_sam10-Dec-06 22:56 
AnswerRe: how to display windows form chart inside webpage? Pin
karam chandrabose11-Dec-06 0:50
karam chandrabose11-Dec-06 0:50 
GeneralRe: how to display windows form chart inside webpage? Pin
Velerena_sam11-Dec-06 20:04
Velerena_sam11-Dec-06 20:04 
QuestionChanging a Column value in a DataRow Pin
Gareth H10-Dec-06 22:46
Gareth H10-Dec-06 22:46 
AnswerRe: Changing a Column value in a DataRow [modified] Pin
Gareth H12-Dec-06 0:27
Gareth H12-Dec-06 0:27 
QuestionRighthand mouse-click to a tree-view should act like a lefthand mouse-click Pin
Schmullus10-Dec-06 22:42
Schmullus10-Dec-06 22:42 
QuestionAVI to 3GP Conversion in C#.Net Pin
Abhilash K10-Dec-06 22:35
Abhilash K10-Dec-06 22:35 
AnswerRe: AVI to 3GP Conversion in C#.Net Pin
chris_do10-Dec-06 23:04
chris_do10-Dec-06 23:04 
Questionoffline web service programming? Pin
George_George10-Dec-06 21:54
George_George10-Dec-06 21:54 

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.