We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to eliminate cell''s border in Grid control

Thread ID:

Created:

Updated:

Platform:

Replies:

91249 Nov 10,2009 08:55 AM Nov 16,2009 10:22 PM Windows Forms 12
loading
Tags: GridControl
Allon
Asked On November 10, 2009 08:55 AM

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

Allon
Replied On November 10, 2009 09:40 AM

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

Ranjeet Kumar [Syncfusion]
Replied On November 11, 2009 05:05 AM

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.zip
Regards,
Ranjeet Kumar

Allon
Replied On November 11, 2009 09:03 AM

Hi Ranjeet,

I use:
V.S 2005
Essential Studio 7.3.0.20

Please, send me version I can use.

Regards,
Allon

Ranjeet Kumar [Syncfusion]
Replied On November 12, 2009 12:51 AM

Hi Allon
Thanks for your update.
You may find the latest sample that uses VS 2005 from the below mentioned location:
CellsBorder2005Version-1268072398.zip


Please, let me know , if you have any query.
Regards
Ranjeet Kumar

Allon
Replied On November 12, 2009 05:55 AM

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

Lingaraj S [Syncfusion]
Replied On November 12, 2009 06:05 AM

Hi Allon,

Sorry for the inconvenience caused.

Please try using the below link to get a VS2005 sample.
GridSample

Please let me know if you have any concerns.'

Regards,
Lingaraj S.

Allon
Replied On November 12, 2009 07:44 AM

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

Allon
Replied On November 12, 2009 08:49 AM

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

Ranjeet Kumar [Syncfusion]
Replied On November 13, 2009 07:22 AM

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.zip

Regards
Ranjeet Kumar

Allon
Replied On November 15, 2009 08:12 AM

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

Kathiresan M [Syncfusion]
Replied On November 16, 2009 11:08 AM

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.zip

If I misunderstood your requirements, please let me know it.

Thanks

Ranjeet Kumar [Syncfusion]
Replied On November 16, 2009 10:22 PM

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.zip

If I misunderstood your requirements, please let me know it.
Regards
Ranjeet Kumar

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;