My Gridview is with dynamically bound Checkbox columns.Columns represent a meeting.
GridViewCheckBoxColumn checkBoxColumn = new GridViewCheckBoxColumn();
var bindingPath = string.Empty;
Binding bind = new Binding();
bindingPath = "MeetingsList[" + meeting.MeetingId + "].IsAdded";
bind = new Binding(bindingPath);
bind.Mode = BindingMode.TwoWay;
bind.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
checkBoxColumn.DataMemberBinding = bind;
checkBoxColumn.IsReadOnly = meeting.IsTrackingDisable;
//meeting.IsTrackingDisable = true;
checkBoxColumn.EditTriggers = GridViewEditTriggers.CellClick;
checkBoxColumn.AutoSelectOnEdit = true;
checkBoxColumn.Header = meeting.Name ;
checkBoxColumn.UniqueName = meeting.MeetingId;
//checkBoxColumn.CellStyle = CheckStyle;
checkBoxColumn.TextAlignment = TextAlignment.Center;
Columns.Add(checkBoxColumn);
The Problem is here I get the checkboxes all Left aligned. I want it to be centered. I tried using the CellStyle. it does the trick but thenI have to Use Checked, Unchecked Events. That is not feacible. So is there a way to set CheckBox centered in C# code?
Thank you in advance