Click here to Skip to main content
15,029,464 members
Home / Discussions / C#
   

C#

 
AnswerRe: What's the best collection Pin
Rob Philpott23-Jun-09 2:16
MemberRob Philpott23-Jun-09 2:16 
AnswerRe: What's the best collection Pin
Mirko198023-Jun-09 2:17
MemberMirko198023-Jun-09 2:17 
Question[Message Deleted] Pin
yams251023-Jun-09 0:36
Memberyams251023-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
MemberEliottA23-Jun-09 3:32 
QuestionWinRTP on .NET C# Platform for streaming Pin
ray_ronnaret23-Jun-09 0:09
Memberray_ronnaret23-Jun-09 0:09 
QuestionMS Chart - Problem to display the records in Range Column Chart Pin
Jegansinna23-Jun-09 0:01
MemberJegansinna23-Jun-09 0:01 
QuestionDatagridview [modified] Pin
mjelten22-Jun-09 23:55
Membermjelten22-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
MemberSevententh22-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
lw@zi 23-Jun-09 1:02
professional lw@zi 23-Jun-09 1:02 
AnswerRe: A better way Pin
Vivek Ragunathan23-Jun-09 2:04
MemberVivek Ragunathan23-Jun-09 2:04 
GeneralRe: A better way Pin
Sevententh23-Jun-09 3:57
MemberSevententh23-Jun-09 3:57 
GeneralRe: A better way Pin
S. Senthil Kumar23-Jun-09 6:26
MemberS. Senthil Kumar23-Jun-09 6:26 
GeneralRe: A better way Pin
Sevententh6-Oct-09 0:02
MemberSevententh6-Oct-09 0:02 
QuestionHow to check whether PC is working with UPS power? Pin
sujithkumarsl22-Jun-09 23:37
Membersujithkumarsl22-Jun-09 23:37 
AnswerRe: How to check whether PC is working with UPS power? Pin
himanshu256122-Jun-09 23:52
Memberhimanshu256122-Jun-09 23:52 
QuestionSaving webservice dll Pin
rmedo22-Jun-09 22:58
Memberrmedo22-Jun-09 22:58 
AnswerRe: Saving webservice dll Pin
DoctorMick23-Jun-09 4:55
MemberDoctorMick23-Jun-09 4:55 
Questionactive directory authentication using C# Pin
rhcp0822-Jun-09 22:54
Memberrhcp0822-Jun-09 22:54 
AnswerRe: active directory authentication using C# Pin
himanshu256122-Jun-09 23:00
Memberhimanshu256122-Jun-09 23:00 
GeneralRe: active directory authentication using C# Pin
rhcp0823-Jun-09 0:52
Memberrhcp0823-Jun-09 0:52 
GeneralRe: active directory authentication using C# Pin
himanshu256123-Jun-09 1:06
Memberhimanshu256123-Jun-09 1:06 
GeneralRe: active directory authentication using C# Pin
rhcp0823-Jun-09 1:24
Memberrhcp0823-Jun-09 1:24 
QuestionDate Time Conversion Pin
papy-boom22-Jun-09 22:45
Memberpapy-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.