Click here to Skip to main content
15,887,746 members
Home / Discussions / C#
   

C#

 
AnswerRe: What's the best collection Pin
Rob Philpott23-Jun-09 2:16
Rob Philpott23-Jun-09 2:16 
AnswerRe: What's the best collection Pin
Mirko198023-Jun-09 2:17
Mirko198023-Jun-09 2:17 
Question[Message Deleted] Pin
yams251023-Jun-09 0:36
yams251023-Jun-09 0:36 
AnswerRe: WPF.... GRID.... !! am lost Pin
Christian Graus23-Jun-09 0:57
protectorChristian Graus23-Jun-09 0:57 
AnswerRe: [Message Deleted] Pin
EliottA23-Jun-09 3:32
EliottA23-Jun-09 3:32 
QuestionWinRTP on .NET C# Platform for streaming Pin
ray_ronnaret23-Jun-09 0:09
ray_ronnaret23-Jun-09 0:09 
QuestionMS Chart - Problem to display the records in Range Column Chart Pin
Jegansinna23-Jun-09 0:01
Jegansinna23-Jun-09 0:01 
QuestionDatagridview [modified] Pin
mjelten22-Jun-09 23:55
mjelten22-Jun-09 23:55 
Hi!

I have ha promblem with adding items to a DataGridViewComboBoxCell. This is what I am doing.






private void SetUpforDataGridView()
{
dataGridViewSearched.ColumnCount = 5;
dataGridViewSearched.ColumnHeadersDefaultCellStyle.BackColor = Color.Navy;
dataGridViewSearched.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
dataGridViewSearched.ColumnHeadersDefaultCellStyle.Font =
new Font(dataGridViewSearched.Font, FontStyle.Bold);

dataGridViewSearched.Name = "Users Searched";
dataGridViewSearched.AutoSizeRowsMode =
DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
dataGridViewSearched.ColumnHeadersBorderStyle =
DataGridViewHeaderBorderStyle.Single;
dataGridViewSearched.CellBorderStyle = DataGridViewCellBorderStyle.Single;
dataGridViewSearched.GridColor = Color.Black;
dataGridViewSearched.RowHeadersVisible = false;
dataGridViewSearched.Dock = DockStyle.Fill;

DataGridViewComboBoxColumn dataGridViewcombobox = new DataGridViewComboBoxColumn();

dataGridViewSearched.Columns.Add(dataGridViewcombobox);


dataGridViewSearched.Columns[0].Name = "UserId";
dataGridViewSearched.Columns[1].Name = "Förnamn";
dataGridViewSearched.Columns[2].Name = "Efternamn";
dataGridViewSearched.Columns[3].Name = "Legitimation";
dataGridViewSearched.Columns[4].Name = "Yrkesroll";
dataGridViewSearched.Columns[5].Name = "Enheter";
dataGridViewSearched.Columns[5].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

dataGridViewSearched.Columns[0].Visible = false;
dataGridViewSearched.Columns[0].DefaultCellStyle.Font =
new Font(dataGridViewSearched.DefaultCellStyle.Font, FontStyle.Italic);

dataGridViewSearched.SelectionMode =
DataGridViewSelectionMode.FullRowSelect;
dataGridViewSearched.MultiSelect = false;
}


And the I am trying to set the table with an object it works fine with the text propertis but not with the DataGridViewComboBoxCell.





public void BindUserList(List<User> userList)
{
dataGridViewSearched.Rows.Clear();
object[] row = new object[5];


foreach (User p in userList)
{
row[0] = p.UserId;
row[1] = p.FirstName;
row[2] = p.LastName;
row[3] = p.MedicalProfession;
row[4] = p.ProfessionalRole;

dataGridViewSearched.Rows.Add(row);

foreach (var unit in p.UnitActivationPeriods)
{
((DataGridViewComboBoxCell)dataGridViewSearched.Rows[dataGridViewSearched.Rows.Count - 1].Cells[5]).Items.Add(unit.ToString());
}

dataGridViewSearched.Rows[dataGridViewSearched.Rows.Count - 1].Tag = p;

}
labelNumberOfUsers.Text = userList.Count.ToString();
dataGridViewSearched.Refresh();
}

Thanks, Mjelten

modified on Tuesday, June 23, 2009 6:51 AM

QuestionA better way Pin
Sevententh22-Jun-09 23:44
Sevententh22-Jun-09 23:44 
AnswerRe: A better way Pin
Christian Graus23-Jun-09 1:00
protectorChristian Graus23-Jun-09 1:00 
AnswerRe: A better way Pin
dan!sh 23-Jun-09 1:02
professional dan!sh 23-Jun-09 1:02 
AnswerRe: A better way Pin
kb-boxer23-Jun-09 2:04
kb-boxer23-Jun-09 2:04 
GeneralRe: A better way Pin
Sevententh23-Jun-09 3:57
Sevententh23-Jun-09 3:57 
GeneralRe: A better way Pin
S. Senthil Kumar23-Jun-09 6:26
S. Senthil Kumar23-Jun-09 6:26 
GeneralRe: A better way Pin
Sevententh6-Oct-09 0:02
Sevententh6-Oct-09 0:02 
QuestionHow to check whether PC is working with UPS power? Pin
sujithkumarsl22-Jun-09 23:37
sujithkumarsl22-Jun-09 23:37 
AnswerRe: How to check whether PC is working with UPS power? Pin
himanshu256122-Jun-09 23:52
himanshu256122-Jun-09 23:52 
QuestionSaving webservice dll Pin
rmedo22-Jun-09 22:58
rmedo22-Jun-09 22:58 
AnswerRe: Saving webservice dll Pin
DoctorMick23-Jun-09 4:55
DoctorMick23-Jun-09 4:55 
Questionactive directory authentication using C# Pin
rhcp0822-Jun-09 22:54
rhcp0822-Jun-09 22:54 
AnswerRe: active directory authentication using C# Pin
himanshu256122-Jun-09 23:00
himanshu256122-Jun-09 23:00 
GeneralRe: active directory authentication using C# Pin
rhcp0823-Jun-09 0:52
rhcp0823-Jun-09 0:52 
GeneralRe: active directory authentication using C# Pin
himanshu256123-Jun-09 1:06
himanshu256123-Jun-09 1:06 
GeneralRe: active directory authentication using C# Pin
rhcp0823-Jun-09 1:24
rhcp0823-Jun-09 1:24 
QuestionDate Time Conversion Pin
papy-boom22-Jun-09 22:45
papy-boom22-Jun-09 22: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.