Удалить серийный номер, который последовательно перекрывает содержимое ячейки datagridview?
Я хочу, чтобы удалить цифры накладывается на ячейку элемента управления datagridview. Что же мне делать??
Скриншот находится здесь:
[Скриншот]
private void SearchForm_Load(object sender, EventArgs e) { DataTable cmbTable = new DataTable(); DataGridViewTextBoxColumn dataGridViewTextBoxColumn = default(DataGridViewTextBoxColumn); int index = 0; int totalWidth = 0; this.WindowState = FormWindowState.Normal; cmbTable.Columns.Add("RecCode"); cmbTable.Columns.Add("TheName"); // set the datagrid columns and width etc for (index = 0; index <= this.displayColumns.Length - 1; index++) { dataGridViewTextBoxColumn = new DataGridViewTextBoxColumn(); dataGridViewTextBoxColumn.DataPropertyName = this.displayColumns[index]; dataGridViewTextBoxColumn.HeaderText = this.displayHeaders[index]; dataGridViewTextBoxColumn.Width = this.displayWidths[index]; this.DgSearch.Columns.Add(dataGridViewTextBoxColumn); totalWidth += this.displayWidths[index]; if (this.DgSearch.DataSource is DataTable) { this.DgSearch.DataSource = ((DataTable)DgSearch.DataSource).DefaultView; } if (index == 0) { this.Text = "Search: "; } cmbTable.Rows.Add(new object[] { this.displayColumns[index], this.displayHeaders[index] }); } this.columnValue = string.Empty; this.Width = totalWidth + 25; // Column Headers in combo box to select the search column name this.CmbColumnName.DisplayMember = "TheName"; this.CmbColumnName.ValueMember = "RecCode"; this.CmbColumnName.DataSource = cmbTable; this.CmbColumnName.SelectedIndex = 0; }
Что я уже пробовал:
Проверка свойства элемента управления datagridview
Это метод краски ниже
protected override void OnRowPostPaint(DataGridViewRowPostPaintEventArgs e) { //this method overrides the DataGridView's RowPostPaint event //in order to automatically draw numbers on the row header cells //and to automatically adjust the width of the column containing //the row header cells so that it can accommodate the new row //numbers, //store a string representation of the row number in 'strRowNumber' string strRowNumber = (e.RowIndex + 1).ToString(); //prepend leading zeros to the string if necessary to improve //appearance. For example, if there are ten rows in the grid, //row seven will be numbered as "07" instead of "7". Similarly, if //there are 100 rows in the grid, row seven will be numbered as "007". while (strRowNumber.Length < this.RowCount.ToString().Length) strRowNumber = "0" + strRowNumber; //determine the display size of the row number string using //the DataGridView's current font. SizeF size = e.Graphics.MeasureString(strRowNumber, this.Font); //adjust the width of the column that contains the row header cells //if necessary if (this.RowHeadersWidth < (int)(size.Width + 20)) this.RowHeadersWidth = (int)(size.Width + 20); //this brush will be used to draw the row number string on the //row header cell using the system's current ControlText color Brush b = SystemBrushes.ControlText; //draw the row number string on the current row header cell using //the brush defined above and the DataGridView's default font e.Graphics.DrawString(strRowNumber, this.Font, b, e.RowBounds.Location.X + 15, e.RowBounds.Location.Y + ((e.RowBounds.Height - size.Height) / 2)); //call the base object's OnRowPostPaint method base.OnRowPostPaint(e); }
Karthik_Mahalingam
покажите код
Member 12562978
Вот этот код
OriginalGriff
Это не очень хороший вопрос - мы не можем понять из этого малого, что вы пытаетесь сделать.
Помните, что мы не можем видеть ваш экран, получить доступ к вашему жесткому диску или прочитать ваши мысли - мы получаем только то, что вы печатаете для работы. И когда все, что вы даете нам, - это очень плохой скриншот, мы понятия не имеем, как вы получили то, что у вас есть: и без кода, который сгенерировал это, мы понятия не имеем, как вам помочь.
Используйте виджет "улучшить вопрос", чтобы отредактировать свой вопрос и предоставить более подробную информацию.
Member 12562978
Вопрос Обновлен