mfc >> MSFlexGrid question.

by Leo Leong » Tue, 25 Nov 2003 21:33:20 GMT

Hi,

Is anyone familiary with MSFlexGrid? I have a question here. I have a
grid with one fixed row, which is the header and contains the names for
several columns. I would like to perform some actions when I click on the
header of a particular column. Does anyone know how this can be done?
Thanks.

Leo




mfc >> MSFlexGrid question.

by Ali R. » Wed, 26 Nov 2003 00:02:54 GMT


You would have to have a event map similar to this, this is for a double
click

BEGIN_EVENTSINK_MAP(LSReportResultDlg, CDialog)
//{{AFX_EVENTSINK_MAP(LSReportResultDlg)
ON_EVENT(LSReportResultDlg, IDC_GRID, -601 /* DblClick */, OnDblClickGrid,
VTS_NONE)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

and in your handler function, you can ask the grid where the clicking was
at.

void LSReportResultDlg::OnDblClickGrid()
{
long mCol = m_Grid.GetMouseCol(); //this is the column that they
double clicked
long mRow = m_Grid.GetMouseRow(); //and this is the row
}

Ali R.









Similar Threads

1. MSFlexGrid Question - Select & Copy

When I right-click on a selection of cells on a MSFlexGrid nothing
happens? Is that normal behavior of that control? (Sorry I'm new at
this).

Whe if I want to select some cells and copy them?

Adam

2. MSflexGrid Question? - Visual Basic/VB

3. MSFlexGrid question

In an MSFlexGrid, how can I detect that the user clicked on what I'll
call the "header row" (I think it's row 0) as opposed to row #1? If he
clicks on the header row, I want to do one thing but, if he clicks on
row 1, I want to do another. 

I find that clicking on the header row sets the .Row property to 1
(instead of 0) just as clicking on row #1 also set the .Row property
to 1.




4. MSFlexGrid Question

5. MSflexgrid question

I need to clear the grid between updates without clearing the header row.
What is the speediest way to do this?
Thanks for your time.


6. MSFlexGrid question - please have a look

7. MSFlexgrid Question!

How would you guys approach this. Im manually populating a MSFLEXGRID
with records from an access database, and displaying it to the user. I
want to give the user an edit button, putting them in an edit mode
that allows them to change any of the data in the cells using floating
textboxes. Once they were done editing they would click a save button
to commit the changes to the database.

I was going to track the changes using a multidimensional array to
store what row/column changed and what the new value was. Then use an
update statement to update the record in the database. However I see
several problems with that.

The first being that the update statement only allows you to update
one field at a time. If say the record contained 20 fields, and the
user changed all the fields in a record, it would require 20 different
updates statements. Which would bring me to my second problem.

If I was populating the changes as they happened in an array, and then
tried to update based on the information in the array, after I did the
first update statement, the data I was trying to compare to using the
where statement will have changed in the database - but not in the
array. Therefore the update statement would be erroneous and not
update any records.

I could store all the changes and all the data that didnt change in an
array for a particular row, and then delete the original record. Then
use data stored in the array to create a new record using the insert
statement. However, I believe there are limitations to how large an
insert statement can be. Like the number of fields it can contain, or
the actual length of the statement itself. I believe I have ran into
that error before.

So if you wanted to do something like this. How would you store the
changes, and how would you commit all the changes at once when the
user wanted to exit the edit mode and save the changes.

Thanks in advance.

8. MSFlexGrid Question - Visual Basic