Is it possible to add two buttons of type DataGridViewButtonCell in the same cell in a DataGridView? I researched a lot and so far I could not find any solution.
Edit 1: For example, I wanted to add a button [Morning] and another [Late] on the same cell ... I tried to add a panel, but it does not accept because the DataGridViewButtonCell is not a Control type.
Edit 2: This is what I can do today ...
Edit3:Well,Ithoughtofasolutionforthisbusinessmodel.@RovannLinhalisgavetheideaofcreatinganextracolumntobeabletosplitrightbetweenMORNINGandAFTERNOON.TheproblemariseswhentheuserchoosestheQUINZENALorMONTHLYcalendaroption,sincemanycolumnswillbegenerated...Well,insteadofaddingncolumns,Iaddedextralines,beingdividedbetweenMORNINGandEVENING.Ex:
ButI'mhavingsomedifficultieswithWindowsFormevents.InthisDataGridViewIamcreatingaRectangleandgivingaDrawStringinitintheRowHeader,foreachline,wheretheroomnumbersappear(FOUR:22).ThiswasthesolutionIfoundbecausetheDataGridViewdoesnothaveRowSpan.
Anyway,theproblemcomesupwhenIselectonelineandthenIselectanother.ItlookslikeRectangleisinvisible...Ex:
Eventcode:
reservaGrid_Grid.CellPainting+=(sender,e)=>{if(e.ColumnIndex==-1&&e.RowIndex>-1){//exibeasdatasemcimadascolunas,desenhandodeduasemduaslinhasfor(inti=0;i<reservaGrid_Grid.RowCount;i+=2){stringquarto=string.Format("Quarto: {0}", Funcoes.String.FindStringAfterCharacter(reservaGrid_Grid.Rows[i].Tag.ToString(), '_') );
Rectangle retangulo = reservaGrid_Grid.GetCellDisplayRectangle(-1, i, false);
//int largura = reservaGrid_Grid.GetCellDisplayRectangle(-1, i + 1, true).Width;
retangulo.X += 1;
retangulo.Y += 1;
retangulo.Width = retangulo.Width / 2 + 15;//largura do header
retangulo.Height = retangulo.Height;//tamanho do header, preenche 2 linhas
StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Center;
format.LineAlignment = StringAlignment.Center;
//pinta o fundo do retangulo
e.Graphics.FillRectangle(
new SolidBrush(
reservaGrid_Grid.ColumnHeadersDefaultCellStyle.BackColor
),
retangulo
);
//desenha a string no retangulo
e.Graphics.DrawString(
quarto,
new Font(reservaGrid_Grid.ColumnHeadersDefaultCellStyle.Font.FontFamily, 13, FontStyle.Bold),
new SolidBrush(reservaGrid_Grid.ColumnHeadersDefaultCellStyle.ForeColor),
retangulo,
format
);
}
}
//reservaGrid_Grid.Invalidate();
};
Why will it be?