Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Column cell value in datagridview not aligning with others

I'm trying to get the data for each cells to align correctly with each other, but for one column the contents are not lining up with the others. I'm not sure why this is, as I have looked over all the default styles and other layout/appearance options and nothing is out of the ordinary. I don't know if this will help but here is a screenshot of the program running in debug mode.

enter image description here

It's just the email column that is off for some reason. I can try and provide more information if it is required.

Thanks

I got the rest to line up but still am having trouble with the email columns

enter image description here

It really is frustrating and makes no sense to me. Would the designer code be useful to take a look at? I can provide it if need be.

Update -

I've noticed its the 4th column (email) on each DGV. Everything else lines up right except for the 4th column. Any ideas?

Update 2 -

Here is the code that is for the datagridview inside the InitializeComponent method:

// 
// dataGridView
// 
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle1.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.dataGridView.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
this.dataGridView.AutoGenerateColumns = false;
this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
this.dataGridView.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
this.dataGridView.BackgroundColor = System.Drawing.Color.White;
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle2.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.dataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2;
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.idDataGridViewTextBoxColumn,
this.firstnameDataGridViewTextBoxColumn,
this.lastnameDataGridViewTextBoxColumn,
this.phonenumberDataGridViewTextBoxColumn,
this.emailaddressDataGridViewTextBoxColumn,
this.birthdayDataGridViewTextBoxColumn,
this.addressDataGridViewTextBoxColumn,
this.marriedDataGridViewTextBoxColumn});
this.dataGridView.DataSource = this.headsBindingSource;
dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle3.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.ControlText;
dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.dataGridView.DefaultCellStyle = dataGridViewCellStyle3;
this.dataGridView.GridColor = System.Drawing.Color.Black;
this.dataGridView.Location = new System.Drawing.Point(20, 63);
this.dataGridView.Name = "dataGridView";
dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle4.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.dataGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle4;
dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle5.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.dataGridView.RowsDefaultCellStyle = dataGridViewCellStyle5;
this.dataGridView.RowTemplate.DefaultCellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
this.dataGridView.RowTemplate.DefaultCellStyle.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.dataGridView.RowTemplate.DefaultCellStyle.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.dataGridView.RowTemplate.Resizable = System.Windows.Forms.DataGridViewTriState.True;
this.dataGridView.Size = new System.Drawing.Size(1028, 426);
this.dataGridView.TabIndex = 0;
this.dataGridView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.dataGridView_KeyDown);

and the email column (4th column)

// emailaddressDataGridViewTextBoxColumn
// 
this.emailaddressDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells;
this.emailaddressDataGridViewTextBoxColumn.DataPropertyName = "email_address";
this.emailaddressDataGridViewTextBoxColumn.HeaderText = "email_address";
this.emailaddressDataGridViewTextBoxColumn.Name = "emailaddressDataGridViewTextBoxColumn";
this.emailaddressDataGridViewTextBoxColumn.Width = 125;
// 

I put the whole solution on dropbox, if anyone can download it and check it out it would be much appreciated - https://www.dropbox.com/s/bh5if8b04eshpo9/QBC%20Members.zip?dl=0

like image 884
user2101411 Avatar asked Nov 07 '22 14:11

user2101411


1 Answers

I set the autosizing of rows to false and added padding and it fixed the alignment issues. Not exactly what I was hoping for but it'll do.

like image 199
user2101411 Avatar answered Dec 09 '22 04:12

user2101411