Data Grid Problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
The value disapears or the selection ?

Ernest


Qumer Mumtaz said:
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.
 
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.
 
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 said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top