Hi everyone,
I'd like to know how can I eliminate cell's border in Grid control (at runtime). I want it to be "None" (in top, bottom, left and right).
Thanks in advance :)
Allon
AL
Allon
November 10, 2009 02:40 PM UTC
I forgot to mention something. My problem is that I don't know how to eliminate the border of the chosen cell in grid control. In my app I tried to cancel some cell selection, and return to the prev cell. Everything went well beside that the cell which supposed to be chosen (and afterword not) remains with his border. I know everything I need to make the unchosen cell a look like it has never chosen, beside it's border (this is the only property which I can't control at runtime).
Regards,
Allon
RK
Ranjeet Kumar
Syncfusion Team
November 11, 2009 10:05 AM UTC
Hi Allon
Thank you for using Syncfusion products.
The borders of the deselected cell to give the appearance of a normal cell can be achieved by handling the events: CellClick and CurrentCellControlDoubleClick.
CellClick event handler helps to select the cell and modify the cell border.
CurrentCellControlDoubleClick event handler helps to unselect the selected cell and resume the default border for the cell.
//create an object of the GridBorder Class and initialize it with required parameters value for removing the border of selected cells.
gb=new GridBorder(GridBorderStyle.None,Color.Black,GridBorderWeight.Thick);
//create an object of the GridBorder Class and initialize it with required parameters value for setting the border of unselected cells.
gb1 = new GridBorder(GridBorderStyle.Standard, Color.Black, GridBorderWeight.Thick);
void gridControl1_CurrentCellControlDoubleClick(object sender, ControlEventArgs e)
{
// gets the column index of the current cell
int col1 = this.gridControl1.CurrentCellInfo.ColIndex;
// gets the row index of the current cell
int row1 = this.gridControl1.CurrentCellInfo.RowIndex;
// assign the GridBorder Class "gb1" as value to the Borders.Bottom property of the control.
this.gridControl1[row1, col1].Borders.Bottom = gb1;
this.gridControl1[row1, col1].Borders.Right = gb1;
this.gridControl1[row1, col1].Borders.Top = gb1;
this.gridControl1[row1, col1].Borders.Left = gb1;
}
void gridControl1_CellClick(object sender, GridCellClickEventArgs e)
{
// This ensures only selected cell will remove its border
if (this.gridControl1.Selections.Count != 0)
{
int col1 = this.gridControl1.CurrentCellInfo.ColIndex;
int row1 = this.gridControl1.CurrentCellInfo.RowIndex;
this.gridControl1[row1, col1].Borders.Bottom = gb;
this.gridControl1[row1, col1].Borders.Top = gb;
this.gridControl1[row1, col1].Borders.Left = gb;
}
}
CellBorderMod704950839.zipRegards,
Ranjeet Kumar
AL
Allon
November 11, 2009 02:03 PM UTC
Hi Ranjeet,
I use:
V.S 2005
Essential Studio 7.3.0.20
Please, send me version I can use.
Regards,
Allon
RK
Ranjeet Kumar
Syncfusion Team
November 12, 2009 05:51 AM UTC
Hi Allon
Thanks for your update.
You may find the latest sample that uses VS 2005 from the below mentioned location:
CellsBorder2005Version-1268072398.zipPlease, let me know , if you have any query.
Regards
Ranjeet Kumar
AL
Allon
November 12, 2009 10:55 AM UTC
Hi Ranjeet,
You sent me an application which was written with Visual Studio 2008 again.
Please, send me something which in V.S 2005.
Thanks in advance,
Allon
LS
Lingaraj S
Syncfusion Team
November 12, 2009 11:05 AM UTC
Hi Allon,
Sorry for the inconvenience caused.
Please try using the below link to get a VS2005 sample.
GridSamplePlease let me know if you have any concerns.'
Regards,
Lingaraj S.
AL
Allon
November 12, 2009 12:44 PM UTC
Hi Lingaraj S.,
Thanks for the nice app. It will be very appreciated if you could add something that I need for my app. It goes like this: In the moment you click on any cell, a message will shown up, and ask you if you want to go back to the prev cell. If you'd click Yes, the usual thing will happen, but if you'd click No, the prev cell will be chosen, and that's it.
Thanks in advance :-)
Allon
AL
Allon
November 12, 2009 01:49 PM UTC
Hi Lingaraj S.,
Sorry about the last request. This one will be much clearer.
It will be very appreciated if you could add something that I need for my app. It goes like this: In the moment you click on any cell, a message will shown up, and ask you if you want to go back to the prev cell. If you'd click No, the usual thing will happen, but if you'd click Yes, the prev cell will be chosen, and therefore, there will be no sign, that you planed to select another cell.
Thanks in advance :-)
Allon
RK
Ranjeet Kumar
Syncfusion Team
November 13, 2009 12:22 PM UTC
Hi Allon,
Thanks for your update.
The requirement of moving to the previous cell on demand through messagebox, can be achieved through the following code.
if (MessageBox.Show("Go Previous Cell", "Previous Cell", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
// event is handled to repaint the clicked cell
this.gridControl1.PrepareViewStyleInfo += new GridPrepareViewStyleInfoEventHandler(gridControl1_PrepareViewStyleInfo);
newCol = col1 - 1;
// To move the cell selection to the previous cell
this.gridControl1.CurrentCell.MoveTo(row1, newCol , GridSetCurrentCellOptions.SetFocus);
e.Cancel = true;
}
void gridControl1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
// Checking the index of the clicked cell
if (e.RowIndex == row1 && e.ColIndex == col1)
// Setting the backcolor of the clicked cell
e.Style.BackColor = Color.Black;
}
Here is a sample in which this has been implemented.
F91249419421825.zipRegards
Ranjeet Kumar
AL
Allon
November 15, 2009 01:12 PM UTC
Hi Ranjeet,
What you have sent me works very well, but I have little problem with that. I use CurrentCellActivated instead of CellClick, because the user can go through the rows with arrows keys (and not with the mouse). I use the grid control as listbox. What I want my app to do is when the user clicks some row, the app will ask him if he sure that he wants to do that selection. What always goes wrong is if the user selects No, everything is coming back to the original state except of the border of the canceled row. It remains solid black. If you want I can send you a piece of code to demonstrate what I mean.
Regrards,
Allon
KM
Kathiresan M
Syncfusion Team
November 16, 2009 04:08 PM UTC
Hi Allon
Thanks for your update.
Here is the code by which you may achieve the requirement.
// Enables multiple row selection
this.gridControl1.ListBoxSelectionMode = SelectionMode.MultiExtended;
this.gridControl1.CurrentCellActivated += new EventHandler(gridControl1_CurrentCellActivated);
// Moves the row focus to the previous row.
this.gridControl1.CurrentCell.MoveTo(cc.row, cc.col, GridSetCurrentCellOptions.SetFocus);
You may find the sample with the above code implemented from the following location
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=WindowsApplication1-1094673234.zipIf I misunderstood your requirements, please let me know it.
Thanks
RK
Ranjeet Kumar
Syncfusion Team
November 17, 2009 03:22 AM UTC
Hi Allon
Thanks for your update.
Here is the code by which you may achieve the requirement.
// Enables multiple row selection
this.gridControl1.ListBoxSelectionMode = SelectionMode.MultiExtended;
this.gridControl1.CurrentCellActivated += new EventHandler(gridControl1_CurrentCellActivated);
// Moves the row focus to the previous row.
this.gridControl1.CurrentCell.MoveTo(cc.row, cc.col, GridSetCurrentCellOptions.SetFocus);
You may find the sample with the above code implemented from the following location
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=WindowsApplication1-1094673234.zipIf I misunderstood your requirements, please let me know it.
Regards
Ranjeet Kumar