Click here to Skip to main content
15,913,944 members
Home / Discussions / C#
   

C#

 
GeneralRe: Cannot use any DLL in Windows Service! Pin
Metal764-Dec-08 21:03
Metal764-Dec-08 21:03 
GeneralRe: Cannot use any DLL in Windows Service! Pin
Metal764-Dec-08 21:06
Metal764-Dec-08 21:06 
GeneralRe: Cannot use any DLL in Windows Service! Pin
Mbah Dhaim4-Dec-08 21:26
Mbah Dhaim4-Dec-08 21:26 
QuestionUsing a custom control Pin
JpGreiner3-Dec-08 20:47
JpGreiner3-Dec-08 20:47 
AnswerRe: Using a custom control Pin
CodingYoshi4-Dec-08 3:20
CodingYoshi4-Dec-08 3:20 
GeneralRe: Using a custom control Pin
JpGreiner4-Dec-08 5:12
JpGreiner4-Dec-08 5:12 
AnswerRe: Using a custom control Pin
JpGreiner4-Dec-08 5:16
JpGreiner4-Dec-08 5:16 
QuestionDataGridViewComboBoxColumn and databinding? Pin
kbalias3-Dec-08 20:37
kbalias3-Dec-08 20:37 
Hi
I am using Visual Studio 2005 and MS Access 2003 to create a Windows application in C#.

I have a DataGridView and I programmatically add a DataGridViewComboBoxColumn to the DataGridView. I populate the ComboBoxes in the DataGridViewComboBoxColumn from a lookup table in the database and bind the DataGridView to a DataTable loaded from another table in the database.

However the correct item in the ComboBox does not get selected. In fact nothing is selected in the ComboBox. Looking at my code it feels to me that I am missing something in my code, but I do not know what.

The doctorTable has a Primary key: Doctor_ID
The patientTable has a Foreign key: Doctor_ID

Using the following code snippets:

private void DataController()
{
    try
    {
        //this methods loads the data from the database into two DataTables: patientTable, doctorTable
        this.LoadData_Controller();
        
        this.FormatDataGridView();

        dgvPatients.DataSource = patientTable;
    }
    catch (Exception ex)
    {
        throw ex;
    }
}



/// <summary>
/// adds a DataGridViewComboBoxColumn to the DataGridView and set the DataSource
/// </summary>
private void FormatDataGridView()
{
    try
    {
        #region Format Doctor column

        //create combobox column for doctors
        DataGridViewComboBoxColumn comboboxColumnDoctors = new DataGridViewComboBoxColumn();
        comboboxColumnDoctors.DataPropertyName = "Doctor";
        comboboxColumnDoctors.HeaderText = "Doctor";

        //add data to new comboboxcolumn
        comboboxColumnDoctors.DataSource = doctorTable;
        comboboxColumnDoctors.ValueMember = "Doctor_ID";
        comboboxColumnDoctors.DisplayMember = "DrName";

        //insert column into datagridview
        dgvPatients.Columns.Insert(3, comboboxColumnDoctors);

        #endregion
    }
    catch (Exception ex)
    {
        throw ex;
    }
}


Any help will be greatly appreciated.

Thanks.

Kobus
AnswerRe: DataGridViewComboBoxColumn and databinding? Pin
CodingYoshi4-Dec-08 3:29
CodingYoshi4-Dec-08 3:29 
AnswerRe: DataGridViewComboBoxColumn and databinding? Pin
u2envy1217-Dec-08 3:01
u2envy1217-Dec-08 3:01 
QuestionDiference between Using Namespace and Namespace.Class.Method in the code.... Pin
BhuvaneswarKumar3-Dec-08 20:09
BhuvaneswarKumar3-Dec-08 20:09 
AnswerRe: Diference between Using Namespace and Namespace.Class.Method in the code.... [modified] Pin
Pedram Behroozi3-Dec-08 20:27
Pedram Behroozi3-Dec-08 20:27 
GeneralRe: Diference between Using Namespace and Namespace.Class.Method in the code.... Pin
BhuvaneswarKumar3-Dec-08 21:46
BhuvaneswarKumar3-Dec-08 21:46 
GeneralRe: Diference between Using Namespace and Namespace.Class.Method in the code.... Pin
User 66583-Dec-08 23:03
User 66583-Dec-08 23:03 
QuestionGNU make Pin
Sinol Jose3-Dec-08 20:09
Sinol Jose3-Dec-08 20:09 
AnswerRe: GNU make Pin
leppie3-Dec-08 20:29
leppie3-Dec-08 20:29 
JokeRe: GNU make Pin
Mbah Dhaim3-Dec-08 20:31
Mbah Dhaim3-Dec-08 20:31 
GeneralRe: GNU make Pin
tonyjsebastian13-Dec-08 22:00
tonyjsebastian13-Dec-08 22:00 
Questionmake file / Make file Pin
tonyjsebastian13-Dec-08 19:50
tonyjsebastian13-Dec-08 19:50 
AnswerRe: make file / Make file Pin
Guffa3-Dec-08 19:56
Guffa3-Dec-08 19:56 
GeneralRe: make file / Make file Pin
tonyjsebastian13-Dec-08 20:01
tonyjsebastian13-Dec-08 20:01 
GeneralRe: make file / Make file Pin
leppie3-Dec-08 20:31
leppie3-Dec-08 20:31 
Questionsearching in sql Pin
rahuladya3-Dec-08 19:31
rahuladya3-Dec-08 19:31 
AnswerRe: searching in sql Pin
dan!sh 3-Dec-08 19:43
professional dan!sh 3-Dec-08 19:43 
GeneralRe: searching in sql Pin
rahuladya3-Dec-08 19:45
rahuladya3-Dec-08 19:45 

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.