Home All Groups Group Topic Archive Search About

DataGrid Format Question

Author
17 Oct 2005 9:30 PM
jake
Is there a way to format a column in a datagrid?  I return a recordset from
a SQL sp with a bit field.  I need to format this field.  Is there a way to
do this?

Thanks

Author
18 Oct 2005 12:39 AM
MikeD
"jake" <j*@broncos.com> wrote in message
news:uYSAiK20FHA.1168@TK2MSFTNGP10.phx.gbl...
> Is there a way to format a column in a datagrid?  I return a recordset
> from a SQL sp with a bit field.  I need to format this field.  Is there a
> way to do this?

Sure.  But we need more information.  For example, are you using
data-binding (I would assume so being that you're using a datagrid)? If
you're data-binding, your options will definitely be limited. But that's not
to say you still can't do it. You'd just need to look into properties of the
datagrid that pertain to formatting/displaying data.  Since I despise
data-binding and such type controls, I can't provide much help. Maybe others
can.

--
Mike
Microsoft MVP Visual Basic
Author
18 Oct 2005 2:57 AM
jake
I am binding to a disconnected recordset.
Show quoteHide quote
"MikeD" <nob***@nowhere.edu> wrote in message
news:ubEsrx30FHA.3336@TK2MSFTNGP12.phx.gbl...
>
> "jake" <j*@broncos.com> wrote in message
> news:uYSAiK20FHA.1168@TK2MSFTNGP10.phx.gbl...
>> Is there a way to format a column in a datagrid?  I return a recordset
>> from a SQL sp with a bit field.  I need to format this field.  Is there a
>> way to do this?
>
> Sure.  But we need more information.  For example, are you using
> data-binding (I would assume so being that you're using a datagrid)? If
> you're data-binding, your options will definitely be limited. But that's
> not to say you still can't do it. You'd just need to look into properties
> of the datagrid that pertain to formatting/displaying data.  Since I
> despise data-binding and such type controls, I can't provide much help.
> Maybe others can.
>
> --
> Mike
> Microsoft MVP Visual Basic
>
>
Author
18 Oct 2005 3:43 AM
Ralph
Show quote Hide quote
"jake" <j*@broncos.com> wrote in message
news:u123UB50FHA.268@TK2MSFTNGP09.phx.gbl...
> I am binding to a disconnected recordset.
> "MikeD" <nob***@nowhere.edu> wrote in message
> news:ubEsrx30FHA.3336@TK2MSFTNGP12.phx.gbl...
> >
> > "jake" <j*@broncos.com> wrote in message
> > news:uYSAiK20FHA.1168@TK2MSFTNGP10.phx.gbl...
> >> Is there a way to format a column in a datagrid?  I return a recordset
> >> from a SQL sp with a bit field.  I need to format this field.  Is there
a
> >> way to do this?
> >
> > Sure.  But we need more information.  For example, are you using
> > data-binding (I would assume so being that you're using a datagrid)? If
> > you're data-binding, your options will definitely be limited. But that's
> > not to say you still can't do it. You'd just need to look into
properties
> > of the datagrid that pertain to formatting/displaying data.  Since I
> > despise data-binding and such type controls, I can't provide much help.
> > Maybe others can.
> >
> > --
> > Mike
> > Microsoft MVP Visual Basic
> >

Your options are not limited, you just have to go about it a little
differently. Take a look at "Data Aware Classes" in the MSDN Help. [Add
Class Module -> Select "Data Source"] Use that as your recordset 'handler'
and 'datasource' for the grid, and do any formatting within it.

However, you might find it easier to just manage the grid directly as MikeD
suggested. In this case create a class (object) to handle the recordset,
passing a reference WithEvents to the DataGrid to it. This gives you the
convenience of managing the entire process inside one module.

Whenever you have a 'data' collection is useful to encapsulate it and then
only expose 'business' services. But it is a matter of style. <g>

-ralph
Author
18 Oct 2005 4:41 AM
Someone
It's possible, but I didn't try it. Look for StdDataFormat object in MSDN.
It has Format/Unformat events so you can use your own custom format on the
fly.

Link:

http://groups.google.com/groups?as_q=vb+StdDataFormat&num=100


Show quoteHide quote
"jake" <j*@broncos.com> wrote in message
news:uYSAiK20FHA.1168@TK2MSFTNGP10.phx.gbl...
> Is there a way to format a column in a datagrid?  I return a recordset
> from a SQL sp with a bit field.  I need to format this field.  Is there a
> way to do this?
>
> Thanks
>
Author
18 Oct 2005 6:11 AM
John
Here's an MSDN article that apologizes for the lame datagrid in .net.
Basically, to display anything resembling what users are used to in a
2005 GUI, you have to subclass and override every component in the
grid.  just look at this 24 page workaround from Microsoft.  I
especially enjoyed the fix needed to make the checkbox (that's what I
think your wanting for your bit field) respond to a single click rather
than a double-click.  The out of the box behavior for the checkbox goes
like this..
* if you are on the row with the checkbox, then just single-click it to
toggle the checkbox.
* if you are currently focused on row N and the user wants to toggle
the checkbox on row M, they must double-click.
Try explaining that to your users with a straight face.
We must have 5000 lines of painfully written code that tries to bring
the datagrid up from the stone age.  Looking back we should have bought
an off the shelf add-on Datagrid.
Ok, rant is over, here's the msdn link...
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwinforms/html/wnf_CustDataGrid.asp


Someone wrote:
Show quoteHide quote
> It's possible, but I didn't try it. Look for StdDataFormat object in MSDN.
> It has Format/Unformat events so you can use your own custom format on the
> fly.
>
> Link:
>
> http://groups.google.com/groups?as_q=vb+StdDataFormat&num=100
>
>
> "jake" <j*@broncos.com> wrote in message
> news:uYSAiK20FHA.1168@TK2MSFTNGP10.phx.gbl...
> > Is there a way to format a column in a datagrid?  I return a recordset
> > from a SQL sp with a bit field.  I need to format this field.  Is there a
> > way to do this?
> >
> > Thanks
> >