Click here to Skip to main content
15,886,199 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to add a ScrollBar where there is none? Pin
Megidolaon6-Mar-09 1:11
Megidolaon6-Mar-09 1:11 
QuestionHow to Loop through this Arraylist Pin
Vimalsoft(Pty) Ltd25-Feb-09 3:03
professionalVimalsoft(Pty) Ltd25-Feb-09 3:03 
AnswerRe: How to Loop through this Arraylist Pin
Colin Angus Mackay25-Feb-09 3:14
Colin Angus Mackay25-Feb-09 3:14 
GeneralRe: How to Loop through this Arraylist Pin
Vimalsoft(Pty) Ltd25-Feb-09 3:29
professionalVimalsoft(Pty) Ltd25-Feb-09 3:29 
AnswerRe: How to Loop through this Arraylist Pin
PIEBALDconsult25-Feb-09 3:54
mvePIEBALDconsult25-Feb-09 3:54 
GeneralRe: How to Loop through this Arraylist Pin
Vimalsoft(Pty) Ltd25-Feb-09 4:05
professionalVimalsoft(Pty) Ltd25-Feb-09 4:05 
GeneralRe: How to Loop through this Arraylist Pin
PIEBALDconsult25-Feb-09 6:51
mvePIEBALDconsult25-Feb-09 6:51 
QuestionChallenge manipulating combobox selectedvalue and selectedvaluechanged Pin
highjo25-Feb-09 2:44
highjo25-Feb-09 2:44 
Hi!
i know people have asked a lot about comboboxes but it's not really about how to get the value or index or whatever.Let me explain.it's users access management application with users, roles and rights:
i have a form editRight with 2 combobox cmbUsers to list users and cmbroles to list role of each users and 3 listboxes.let's pause here

on load event i fill users combobox with users

 private void EditRight_Load(object sender, EventArgs e)<br />
        {<br />
            try<br />
            {<br />
            //Load the user list in the dt_users dataset.dt_users and dt_roles are declare as global variables<br />
            dt_users = UserManager.FindAll().Tables[0];<br />
            //set the combobox cmbUsers datasource<br />
            cmbUsers.DataSource = dt_users.DefaultView;<br />
            //set display member and value member<br />
            cmbUsers.DisplayMember = "user_name";<br />
            cmbUsers.ValueMember = "user_id";<br />
<br />
                CallFillRoleCombo((int)cmbUsers.SelectedValue);<br />
            }<br />
            catch (System.Exception ex)<br />
            {<br />
                MessageBox.Show(ex.Message);<br />
            }<br />
        }<br />
<br />
        private void CallFillRoleCombo(int uid)<br />
        {<br />
            try<br />
            {<br />
                //load users roles into dt_roles database<br />
                dt_roles = UserRoleManager.FindByUser(uid).Tables[0];<br />
<br />
                //set combobox datasource<br />
                cmbroles.DataSource = dt_roles.DefaultView;<br />
                cmbroles.DisplayMember = dt_roles.Columns[2].ToString();<br />
                cmbroles.ValueMember = dt_roles.Columns[1].ToString();<br />
            }<br />
            catch (System.Exception ex)<br />
            {<br />
                MessageBox.Show(ex.Message);<br />
            }<br />
            <br />
        }<br />
<br />
        private void cmbUsers_SelectedValueChanged(object sender, EventArgs e)<br />
        {<br />
            CallFillRoleCombo((int)cmbUsers.SelectedValue);<br />
        }<br />


when i run the code its throws exception:Object reference not set to an instance of an object.It seems that its calling the cmbUsers_SelectedValueChanged eventhandler when setting the display member of the cmbUsers combobox.
How to work around it?Thank you for reading this.

eager to learn

AnswerRe: Challenge manipulating combobox selectedvalue and selectedvaluechanged Pin
Cracked-Down25-Feb-09 3:00
Cracked-Down25-Feb-09 3:00 
AnswerRe: Challenge manipulating combobox selectedvalue and selectedvaluechanged Pin
Xmen Real 25-Feb-09 3:14
professional Xmen Real 25-Feb-09 3:14 
AnswerRe: Challenge manipulating combobox selectedvalue and selectedvaluechanged Pin
highjo25-Feb-09 7:39
highjo25-Feb-09 7:39 
GeneralRe: Challenge manipulating combobox selectedvalue and selectedvaluechanged Pin
Cracked-Down25-Feb-09 17:55
Cracked-Down25-Feb-09 17:55 
QuestionHow to populate a CheckBox list from a based on a table in a database? Pin
Balagurunathan S25-Feb-09 2:33
Balagurunathan S25-Feb-09 2:33 
AnswerRe: How to populate a CheckBox list from a based on a table in a database? Pin
Wendelius25-Feb-09 8:16
mentorWendelius25-Feb-09 8:16 
QuestionMake pdf from cristal report, How ? Pin
E_Gold25-Feb-09 2:13
E_Gold25-Feb-09 2:13 
AnswerRe: Make pdf from cristal report, How ? Pin
Wendelius25-Feb-09 8:12
mentorWendelius25-Feb-09 8:12 
QuestionDisplaying a very long folder path Pin
Dewald25-Feb-09 1:59
Dewald25-Feb-09 1:59 
AnswerRe: Displaying a very long folder path Pin
benjymous25-Feb-09 2:15
benjymous25-Feb-09 2:15 
AnswerRe: Displaying a very long folder path Pin
moon_stick25-Feb-09 3:32
moon_stick25-Feb-09 3:32 
GeneralRe: Displaying a very long folder path Pin
Dewald26-Feb-09 0:36
Dewald26-Feb-09 0:36 
QuestionMicrosoft Report Viewer Pin
mehrdadc4825-Feb-09 1:22
mehrdadc4825-Feb-09 1:22 
QuestionWhat do I need? Pin
staticv25-Feb-09 1:03
staticv25-Feb-09 1:03 
AnswerRe: What do I need? Pin
Xmen Real 25-Feb-09 1:21
professional Xmen Real 25-Feb-09 1:21 
GeneralRe: What do I need? [modified] Pin
staticv25-Feb-09 1:36
staticv25-Feb-09 1:36 
GeneralRe: What do I need? Pin
Xmen Real 25-Feb-09 1:49
professional Xmen Real 25-Feb-09 1:49 

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.