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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

how to make the edit bit of the MonthCalendar readonly...

Thread ID:

Created:

Updated:

Platform:

Replies:

17641 Aug 13,2004 07:41 AM UTC Feb 28,2006 03:10 PM UTC WinForms 6
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On August 13, 2004 07:41 AM UTC

how can i make the edit bit of the MonthCalendar readonly... basically beacuse if i set a format eg "ddd dd MMM yyyy" then it insists the user types it in in that format too, so they get 29 Sep 2004 is not a vlid date!

Administrator [Syncfusion]
Replied On August 13, 2004 08:21 AM UTC

I am not sure I understand what you are asking. Is it that you want to make it impossible for the user to type into the grid cell? If so, here are a couple of ways you can do this. One is to set the style.ReadOnly = true for that cell. Another is to handle the CurrentCellStartEditing event, and if grid.CurrentCell.RowIndex and grid.CurrentCell.ColIndex point to this cell, then set e.Cancel = true.

Administrator [Syncfusion]
Replied On August 15, 2004 03:41 PM UTC

wont making it readonly mean that the user cant use the drop down control i''ll give the begin edit a try though.. although as i say the ''real'' problem is that i think that a user should be able to enter a date in any standard form and not the one thats its beeing formatted in....ie its nice to see the day of the week, but a user shouldn''t be forced to enter it....

Administrator [Syncfusion]
Replied On August 15, 2004 06:54 PM UTC

ReadOnly will prevent changing the cell value. Here are two events that you can handle to prevent typing into the cell, but still allow changing from the dropdown.
private void gridDataBoundGrid1_CurrentCellStartEditing(object sender, CancelEventArgs e)
{
	GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
	if(cc.ColIndex == 2)
	{
		e.Cancel = true;
	}
}

private void gridDataBoundGrid1_CurrentCellCloseDropDown(object sender, PopupClosedEventArgs e)
{
	GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
	if(cc.ColIndex == 2)
	{
		cc.ConfirmChanges();
	}
}

Pierre-Luc
Replied On February 27, 2006 09:05 PM UTC

Hello there, I have the same needs here, and I''m coding in VB.net. I attached a sample of the way I used the code you just gave, but somehow when you choose a date in the calendar dropdown and then switch the focus to anything else, the date in the cell disapears. did I do something wrong? I also need, when the date will be available, to be able to Update a database field on an event that happens when the date as been selected, can you please tell me which it would be? Thanks for being so much support to us all Pierre-Luc

MonthCalendarExemple.zip

stanleyj [Syncfusion]
Replied On February 28, 2006 05:30 AM UTC

Hi Pierre-Luc, Try handling CurrentCellKeyDown and CurrentCellKeyPress handlers to block the keyboard entries instead of CurrentCellStartEditing and CurrentCellCloseDropDown. Private Sub gridControl1_CurrentCellKeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Dim cc As GridCurrentCell = Me.gridControl1.CurrentCell If cc.ColIndex = 2 AndAlso (e.KeyCode = Keys.Delete OrElse e.KeyCode = Keys.Back) Then e.Handled = True End If End Sub Private Sub gridControl1_CurrentCellKeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Dim cc As GridCurrentCell = Me.gridControl1.CurrentCell If cc.ColIndex = 2 Then e.Handled = True End If End Sub Best regards, Stanley

Pierre-Luc
Replied On February 28, 2006 03:10 PM UTC

wow! thanks ^_^ it worked perfectly Pierre-Luc

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.

Warning Icon 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.Close Icon

;