By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,837 Members | 1,813 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,837 IT Pros & Developers. It's quick & easy.

Data Grid Problem

P: n/a
h
I am using a datagrid control. I am displaying some controls like Date Time picker, combo boxes, ect in some cells.When a particuler cell is got focus the control is displayed and user select the value from combo or from date time picker control.When the focus is last the control disappeares and the value that user selected using the control is also lost. I want when focous is lost the value still remain there in the cell. How to do this.
Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
The value disapears or the selection ?

Ernest
"Qumer Mumtaz" <qa***@alrahmahsoft.com> wrote in message
news:8E**********************************@microsof t.com...
hi
I am using a datagrid control. I am displaying some controls like Date

Time picker, combo boxes, ect in some cells.When a particuler cell is got
focus the control is displayed and user select the value from combo or from
date time picker control.When the focus is last the control disappeares and
the value that user selected using the control is also lost. I want when
focous is lost the value still remain there in the cell. How to do this.
Nov 16 '05 #2

P: n/a
Values is disapeared...................there is no value in the cell intially. When the cell got focus data time picker control apeare.o
I make a selction of date, so for as the focus is on the current cell data time picker is visible
when focus is lost the control is disappeared and value as well. What I wanna do is,when focus is lost the cell date time control must disappeare and the selected value becomes the current text of the cell.Just as happened in MS Project's Gentt Chart.
Nov 16 '05 #3

P: n/a
>When the cell got focus data time picker control apeare.ok

So you derived from DataGridColumnStyle. Maybe you don't write the selected
value(in the DateTime picker) into the row of your datasource.

You should associate an eventhandler to the event
DateTime.SelectedValueChanged. In this event handler you need to write
something like:

private void myDTPicker(object sendere, EventArgs e)
{
this.ColumnStartedEditing(this.myDateTimePicker);
}

You also should associate an event handler to the Leave event of the
DateTimePicker control

private void myDTPicker(object sendere, EventArgs e)
{
myDTPicker.Hide();
}

And finally, you should override the Commit method of the base class:

protected overrides bool Commit(System.Windows.Forms.CurrencyManager
dataSource , int rowNum )
{
if(rowNum>-1 && dataSource!=null)
this.SetColumnValueAtRow(dataSource, rowNum,
myDtPicker.SelectedValue);
}

Be also sure you are painting(in the Paint method) the value from the
DataSource, that is: (DateTime)this.GetColumnValue(source,rowNum)

Ernest

"Qumer Mumtaz" <an*******@discussions.microsoft.com> wrote in message
news:CB**********************************@microsof t.com...
Values is disapeared...................there is no value in the cell intially. When the cell got focus data time picker control apeare.ok I make a selction of date, so for as the focus is on the current cell data time picker is visible. when focus is lost the control is disappeared and value as well. What I

wanna do is,when focus is lost the cell date time control must disappeare
and the selected value becomes the current text of the cell.Just as happened
in MS Project's Gentt Chart.
Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.