Click to See Complete Forum and Search --> : Bound DBGrid: How find out Row Selection , and one more problem


Ravi Kiran
November 23rd, 1999, 11:37 PM
In Bound DbGrid, a row can be selected by clicking on the First Column ( where it displays '>' ). Now how do i know that a row has been selected? Say i want to allow "Select" btn only after a row has been selected?
I Cannot depend on the underlying record set objects current record, because there will be a valid record even if i click on any of the columns.
ANd i Dont want to set the mode to select the entire row on click anywhere .


2. MSDN Docs say SelStartRow and SelEndRow are defined for DBGrid. But i dont see those properties in a bound DBGrid. Is that because it is bound?

3. IF i want to make one of the colums (ie Filed on the underlying recset ) not visible ( and hence not editable by user) how can i do it? Is sql the only way out?

Answers for any/all of the questions will be rewarded with Points :-)

RK

RK

Lothar Haensler
November 24th, 1999, 02:08 AM
have you tried the LayOut tab in the properties dialog of the dbgrid?
there is a "visible" check box. if you click it "off", the column is invisible.

Lothar Haensler
November 24th, 1999, 02:14 AM
there is a SelChange Event that seems to be triggered whenever a different row is clicked in the first column of a row.

Lothar Haensler
November 24th, 1999, 02:18 AM
I just created a dbgrid in vb 6.
to get the selected rows:
grid.selbookmarks.count tells you the number of selected (=marked) rows
grid.selbookmarks.item(0) the row number ot the first selected row and so on...

Ravi Kiran
November 24th, 1999, 02:31 AM
Thanks a lot Lother.

I dont know how i missed this!... like they say when you are too keen to do something, you will miss the bigger picture!:-)

BTW, SelChange triggers for both Row and Col header click, this coupled with .SelStartCol and SelEndCol can be used to deferentiate between them, i think

Thanks again

RK

Ravi Kiran
November 24th, 1999, 02:47 AM
This point i had noticed after posting. I was banking on this with a timer event...etc

For a Bound Grid the SelBookMarks count always seems to be 1 or 0, because they inturn represent current record and you cant have more than 1.

I couldn't use the Layout because the no. of cols is not const and the record set is set at run time... i found out that we can use the Columns collection & COlumn property to set this. Both Visibility and Width.

But that leaves out one more problem i posted yeterday: How to get the height of the fixed row ?!

Thanks again.


RK