Click here to Skip to main content
15,891,253 members
Home / Discussions / C#
   

C#

 
GeneralRe: Problem at second connection attempt Pin
sleepyman11-Jan-10 4:15
sleepyman11-Jan-10 4:15 
GeneralRe: Problem at second connection attempt Pin
OriginalGriff11-Jan-10 4:37
mveOriginalGriff11-Jan-10 4:37 
GeneralRe: Problem at second connection attempt Pin
sleepyman11-Jan-10 5:57
sleepyman11-Jan-10 5:57 
GeneralRe: Problem at second connection attempt Pin
OriginalGriff11-Jan-10 8:19
mveOriginalGriff11-Jan-10 8:19 
QuestionRead in Cyrillic, Arabic, Japanese with GetWindowText not working Pin
elmernite11-Jan-10 3:04
elmernite11-Jan-10 3:04 
AnswerMessage Closed Pin
11-Jan-10 3:14
stancrm11-Jan-10 3:14 
QuestionRe: Read in Cyrillic, Arabic, Japanese with GetWindowText not working Pin
elmernite11-Jan-10 3:24
elmernite11-Jan-10 3:24 
QuestionWhat's the best way to determine viewable portion of custom heading in DataGridView? Pin
arnold_w11-Jan-10 2:34
arnold_w11-Jan-10 2:34 
I want to create a DataGridView with custom headings. Basically, I want to place a Panel with a number of controls in each heading cell. To do this I have created a new class which inherits DataColumn:
public class GenericDataColumn : DataColumn
{
  private int columnIndex;
  private string columnName;
  private Panel panel;
  private DataGridView table;
  private Size initialPanelSize;
  private Point[] initialControlLocations;

  public GenericDataColumn(int columnIndex,
                           string columnName,
                           Panel panel,
                           DataGridView table)
  {
    this.columnIndex = columnIndex;
    this.ColumnName = columnName;
    this.table = table;
    this.panel = panel;
    this.initialPanelSize = panel.Size;
    this.initialControlLocations = new Point[panel.Controls.Count];
    for (int i = 0; i < panel.Controls.Count; i++)
    {
      initialControlLocations[i] = panel.Controls[i].Location;
    }
  }
}

Whenever the table is scrolled or resized or the column is resized I need to resize the Panel and possibly move around the controls inside the Panel. I wrote the following method to do that:
private void cutPanel(int cutFromLeft, int cutFromRight)
{
  // Determine new panel width
  int newPanelWidth = initialPanelSize.Width;
  if (0 < cutFromLeft)
  {
    newPanelWidth -= cutFromLeft;
  }
  if (0 < cutFromRight)
  {
    newPanelWidth -= cutFromRight;
  }
  panel.Width = newPanelWidth;

  // Move around components appropriately
  if (0 <= cutFromLeft)
  {
    for (int i = 0; i < panel.Controls.Count; i++)
    {
      panel.Controls[i].Location = new Point(
        initialControlLocations[i].X - cutFromLeft,
        initialControlLocations[i].Y);
    }
  }
}

In the Paint event I can easily determine what the new position and dimension of the Panel should be:
DataGridView.GetCellDisplayRectangle(columnIndex, -1, true);

However, this information alone is not enough to determine the cutFromLeft and cutFromRight parameters in the cutPanel method. What's the best way to determine those parameters? Am I forced to micro-manage all the "geography-related" events (DataGridView scroll, DataGridView resize, and column resize) or is there an easier way to do it?
AnswerRe: What's the best way to determine viewable portion of custom heading in DataGridView? Pin
dan!sh 11-Jan-10 3:32
professional dan!sh 11-Jan-10 3:32 
GeneralRe: What's the best way to determine viewable portion of custom heading in DataGridView? Pin
arnold_w11-Jan-10 3:39
arnold_w11-Jan-10 3:39 
GeneralRe: What's the best way to determine viewable portion of custom heading in DataGridView? Pin
dan!sh 11-Jan-10 3:45
professional dan!sh 11-Jan-10 3:45 
GeneralRe: What's the best way to determine viewable portion of custom heading in DataGridView? Pin
arnold_w11-Jan-10 3:50
arnold_w11-Jan-10 3:50 
GeneralRe: What's the best way to determine viewable portion of custom heading in DataGridView? Pin
arnold_w11-Jan-10 3:53
arnold_w11-Jan-10 3:53 
GeneralRe: What's the best way to determine viewable portion of custom heading in DataGridView? Pin
dan!sh 11-Jan-10 4:00
professional dan!sh 11-Jan-10 4:00 
QuestionCustom Control expandable property ordering [solved] Pin
OriginalGriff11-Jan-10 1:54
mveOriginalGriff11-Jan-10 1:54 
AnswerRe: Custom Control expandable property ordering. Pin
Martin#11-Jan-10 3:43
Martin#11-Jan-10 3:43 
GeneralRe: Custom Control expandable property ordering. Pin
OriginalGriff11-Jan-10 3:57
mveOriginalGriff11-Jan-10 3:57 
GeneralRe: Custom Control expandable property ordering. Pin
Martin#11-Jan-10 4:01
Martin#11-Jan-10 4:01 
QuestionMouse Wheel Scroll Pin
Pavan Navali11-Jan-10 0:44
Pavan Navali11-Jan-10 0:44 
AnswerRe: Mouse Wheel Scroll Pin
Covean11-Jan-10 1:35
Covean11-Jan-10 1:35 
AnswerRe: Mouse Wheel Scroll Pin
PIEBALDconsult11-Jan-10 3:52
mvePIEBALDconsult11-Jan-10 3:52 
QuestionLooping through XMLNodeList problem Pin
jamesc6910-Jan-10 23:32
jamesc6910-Jan-10 23:32 
AnswerRe: Looping through XMLNodeList problem Pin
Keith Barrow11-Jan-10 0:00
professionalKeith Barrow11-Jan-10 0:00 
GeneralRe: Looping through XMLNodeList problem Pin
jamesc6911-Jan-10 0:05
jamesc6911-Jan-10 0:05 
GeneralRe: Looping through XMLNodeList problem [modified] Pin
Keith Barrow11-Jan-10 0:11
professionalKeith Barrow11-Jan-10 0:11 

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.