Customizing FlexGrid w/ a check box

V

VR

I am trying to embed a check box into a FlexGrid's cell,
but having a problem when I start scrolling the grid.

Here is my MyCheckBox class...

class MyCheckBox : CheckBox
{
void Init
(
AxMSFlexGridLib.AxMSFlexGrid oGrid,
int iRow,
int iCol
)
{
...

this.Name = "GridCheckBox";
this.TabIndex = 3;

this.Text = "";
this.CheckAlign =
System.Drawing.ContentAlignment.MiddleCenter;

this.Top = ... // calculate based on iRow, iCol
this.Left = ... // calculate based on iRow, iCol
this.Height = ... // calculate based on iRow, iCol
this.Width = ... // calculate based on iRow, iCol

oGrid.Controls.Add(this);
}
}

Whenever I need a checkbox in a grid's cell I create one
and add it to the grid:

class MyGrid : AxMSFlexGridLib.AxMSFlexGrid
{

void Foo()
{
MyCheckBox oCheckBox = new MyCheckBox();
oCheckBox.Init(this, iRow, iCol);
}
}

Everything works fine when I create the check box -- it
does appear above the [iRow, iCol] cell, but it gets
shifted as soon as I start scrolling the grid.

1. Did I choose the right approach for this?
2. Do I need to move my check box myself based on what
happens with the grid?
3. If I do, what is the best approach for it?

Any suggestions/comments are greatly appreciated!

Thanks,
VR
 
J

Jeffrey Tan[MSFT]

Hi VR,

Is your project web based or winform based?
I think in .net, you can use DataGrid instead of using FlexGrid.
Because your checkbox's position was calculated at initialization time, you
should calculate again when the flexgrid was scrolling.

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "VR" <[email protected]>
| Sender: "VR" <[email protected]>
| Subject: Customizing FlexGrid w/ a check box
| Date: Sat, 30 Aug 2003 19:02:42 -0700
| Lines: 58
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcNvY/alFamRgfAtRmm+AcYFCMvscA==
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:181086
| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| I am trying to embed a check box into a FlexGrid's cell,
| but having a problem when I start scrolling the grid.
|
| Here is my MyCheckBox class...
|
| class MyCheckBox : CheckBox
| {
| void Init
| (
| AxMSFlexGridLib.AxMSFlexGrid oGrid,
| int iRow,
| int iCol
| )
| {
| ...
|
| this.Name = "GridCheckBox";
| this.TabIndex = 3;
|
| this.Text = "";
| this.CheckAlign =
| System.Drawing.ContentAlignment.MiddleCenter;
|
| this.Top = ... // calculate based on iRow, iCol
| this.Left = ... // calculate based on iRow, iCol
| this.Height = ... // calculate based on iRow, iCol
| this.Width = ... // calculate based on iRow, iCol
|
| oGrid.Controls.Add(this);
| }
| }
|
| Whenever I need a checkbox in a grid's cell I create one
| and add it to the grid:
|
| class MyGrid : AxMSFlexGridLib.AxMSFlexGrid
| {
|
| void Foo()
| {
| MyCheckBox oCheckBox = new MyCheckBox();
| oCheckBox.Init(this, iRow, iCol);
| }
| }
|
| Everything works fine when I create the check box -- it
| does appear above the [iRow, iCol] cell, but it gets
| shifted as soon as I start scrolling the grid.
|
| 1. Did I choose the right approach for this?
| 2. Do I need to move my check box myself based on what
| happens with the grid?
| 3. If I do, what is the best approach for it?
|
| Any suggestions/comments are greatly appreciated!
|
| Thanks,
| VR
|
 
V

VR

Thanks, Jeffrey.

My project is WinForm based and for some reason I am
having a hard time catching scroll events. The reason I
didn't use DataGrid is because I couldn't figure out how
to add/remove rows easily, or to set the number of
rows/columns. Like this:

gridFlex.Rows = 2;
gridFlex.Cols = 3;
gridFlex.AddItem("item");
gridFlex.get_TextMatrix(1, 1);

Are there any samples you could recomend for both
MSFlexGrid and DataGrid (MSFlexGrid preferably) that would
show how to add different controls to grid's cells? Seems
like it's a fairly common technique, yet, I couldn't find
anything in MSDN on that.

Thank for the help.

VR


-----Original Message-----

Hi VR,

Is your project web based or winform based?
I think in .net, you can use DataGrid instead of using FlexGrid.
Because your checkbox's position was calculated at initialization time, you
should calculate again when the flexgrid was scrolling.

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "VR" <[email protected]>
| Sender: "VR" <[email protected]>
| Subject: Customizing FlexGrid w/ a check box
| Date: Sat, 30 Aug 2003 19:02:42 -0700
| Lines: 58
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcNvY/alFamRgfAtRmm+AcYFCMvscA==
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:181086
| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| I am trying to embed a check box into a FlexGrid's cell,
| but having a problem when I start scrolling the grid.
|
| Here is my MyCheckBox class...
|
| class MyCheckBox : CheckBox
| {
| void Init
| (
| AxMSFlexGridLib.AxMSFlexGrid oGrid,
| int iRow,
| int iCol
| )
| {
| ...
|
| this.Name = "GridCheckBox";
| this.TabIndex = 3;
|
| this.Text = "";
| this.CheckAlign =
| System.Drawing.ContentAlignment.MiddleCenter;
|
| this.Top = ... // calculate based on iRow, iCol
| this.Left = ... // calculate based on iRow, iCol
| this.Height = ... // calculate based on iRow, iCol
| this.Width = ... // calculate based on iRow, iCol
|
| oGrid.Controls.Add(this);
| }
| }
|
| Whenever I need a checkbox in a grid's cell I create one
| and add it to the grid:
|
| class MyGrid : AxMSFlexGridLib.AxMSFlexGrid
| {
|
| void Foo()
| {
| MyCheckBox oCheckBox = new MyCheckBox();
| oCheckBox.Init(this, iRow, iCol);
| }
| }
|
| Everything works fine when I create the check box -- it
| does appear above the [iRow, iCol] cell, but it gets
| shifted as soon as I start scrolling the grid.
|
| 1. Did I choose the right approach for this?
| 2. Do I need to move my check box myself based on what
| happens with the grid?
| 3. If I do, what is the best approach for it?
|
| Any suggestions/comments are greatly appreciated!
|
| Thanks,
| VR
|

.
 
J

Jeffrey Tan[MSFT]

Hi VR,

To add a new row to datagrid, you can add a new row to the dataset and then
bind it to the datagrid.
To add control to the datagrid, there is a good sample here:
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:
80/support/kb/articles/q323/1/67.asp&NoWebContent=1

This sample shows what you should do with the control when you scroll the
datagrid.

Hope this helps.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "VR" <[email protected]>
| Sender: "VR" <[email protected]>
| References: <[email protected]>
<[email protected]>
| Subject: RE: Customizing FlexGrid w/ a check box
| Date: Tue, 2 Sep 2003 09:41:53 -0700
| Lines: 131
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcNxcR1ttCtiegKdRyO8kJjDNCH6vg==
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:181603
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Thanks, Jeffrey.
|
| My project is WinForm based and for some reason I am
| having a hard time catching scroll events. The reason I
| didn't use DataGrid is because I couldn't figure out how
| to add/remove rows easily, or to set the number of
| rows/columns. Like this:
|
| gridFlex.Rows = 2;
| gridFlex.Cols = 3;
| gridFlex.AddItem("item");
| gridFlex.get_TextMatrix(1, 1);
|
| Are there any samples you could recomend for both
| MSFlexGrid and DataGrid (MSFlexGrid preferably) that would
| show how to add different controls to grid's cells? Seems
| like it's a fairly common technique, yet, I couldn't find
| anything in MSDN on that.
|
| Thank for the help.
|
| VR
|
|
|
| >-----Original Message-----
| >
| >Hi VR,
| >
| >Is your project web based or winform based?
| >I think in .net, you can use DataGrid instead of using
| FlexGrid.
| >Because your checkbox's position was calculated at
| initialization time, you
| >should calculate again when the flexgrid was scrolling.
| >
| >Hope this helps.
| >
| >Best regards,
| >Jeffrey Tan
| >Microsoft Online Partner Support
| >Get Secure! - www.microsoft.com/security
| >This posting is provided "as is" with no warranties and
| confers no rights.
| >
| >--------------------
| >| Content-Class: urn:content-classes:message
| >| From: "VR" <[email protected]>
| >| Sender: "VR" <[email protected]>
| >| Subject: Customizing FlexGrid w/ a check box
| >| Date: Sat, 30 Aug 2003 19:02:42 -0700
| >| Lines: 58
| >| Message-ID: <[email protected]>
| >| MIME-Version: 1.0
| >| Content-Type: text/plain;
| >| charset="iso-8859-1"
| >| Content-Transfer-Encoding: 7bit
| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| >| Thread-Index: AcNvY/alFamRgfAtRmm+AcYFCMvscA==
| >| Newsgroups: microsoft.public.dotnet.languages.csharp
| >| Path: cpmsftngxa06.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.languages.csharp:181086
| >| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
| >| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
| >|
| >| I am trying to embed a check box into a FlexGrid's
| cell,
| >| but having a problem when I start scrolling the grid.
| >|
| >| Here is my MyCheckBox class...
| >|
| >| class MyCheckBox : CheckBox
| >| {
| >| void Init
| >| (
| >| AxMSFlexGridLib.AxMSFlexGrid oGrid,
| >| int iRow,
| >| int iCol
| >| )
| >| {
| >| ...
| >|
| >| this.Name = "GridCheckBox";
| >| this.TabIndex = 3;
| >|
| >| this.Text = "";
| >| this.CheckAlign =
| >| System.Drawing.ContentAlignment.MiddleCenter;
| >|
| >| this.Top = ... // calculate based on iRow, iCol
| >| this.Left = ... // calculate based on iRow, iCol
| >| this.Height = ... // calculate based on iRow, iCol
| >| this.Width = ... // calculate based on iRow, iCol
| >|
| >| oGrid.Controls.Add(this);
| >| }
| >| }
| >|
| >| Whenever I need a checkbox in a grid's cell I create
| one
| >| and add it to the grid:
| >|
| >| class MyGrid : AxMSFlexGridLib.AxMSFlexGrid
| >| {
| >|
| >| void Foo()
| >| {
| >| MyCheckBox oCheckBox = new MyCheckBox();
| >| oCheckBox.Init(this, iRow, iCol);
| >| }
| >| }
| >|
| >| Everything works fine when I create the check box -- it
| >| does appear above the [iRow, iCol] cell, but it gets
| >| shifted as soon as I start scrolling the grid.
| >|
| >| 1. Did I choose the right approach for this?
| >| 2. Do I need to move my check box myself based on what
| >| happens with the grid?
| >| 3. If I do, what is the best approach for it?
| >|
| >| Any suggestions/comments are greatly appreciated!
| >|
| >| Thanks,
| >| VR
| >|
| >
| >.
| >
|
 
V

VR

Thanks Jeffery.

I did find your reply very helpful. In general I try post
a reply in the Newsgroup, thanking a contributor, but
since I am sort of new to the process, I wasn't sure
whether it's customary to thank people or it just forces
them to read yet another message from me. So, since I
didn't see a lot of thankful responses in other threads, I
assumed it's how the things are done.

I can see I could have been wrong and saying thanks never
hurts.

So, thanks again.

VR
-----Original Message-----

Hi VR,

To add a new row to datagrid, you can add a new row to the dataset and then
bind it to the datagrid.
To add control to the datagrid, there is a good sample here:
scid=http://support.microsoft.com:
80/support/kb/articles/q323/1/67.asp&NoWebContent=1

This sample shows what you should do with the control when you scroll the
datagrid.

Hope this helps.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "VR" <[email protected]>
| Sender: "VR" <[email protected]>
| References: <[email protected]>
<[email protected]>
| Subject: RE: Customizing FlexGrid w/ a check box
| Date: Tue, 2 Sep 2003 09:41:53 -0700
| Lines: 131
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcNxcR1ttCtiegKdRyO8kJjDNCH6vg==
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:181603
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Thanks, Jeffrey.
|
| My project is WinForm based and for some reason I am
| having a hard time catching scroll events. The reason I
| didn't use DataGrid is because I couldn't figure out how
| to add/remove rows easily, or to set the number of
| rows/columns. Like this:
|
| gridFlex.Rows = 2;
| gridFlex.Cols = 3;
| gridFlex.AddItem("item");
| gridFlex.get_TextMatrix(1, 1);
|
| Are there any samples you could recomend for both
| MSFlexGrid and DataGrid (MSFlexGrid preferably) that would
| show how to add different controls to grid's cells? Seems
| like it's a fairly common technique, yet, I couldn't find
| anything in MSDN on that.
|
| Thank for the help.
|
| VR
|
|
|
| >-----Original Message-----
| >
| >Hi VR,
| >
| >Is your project web based or winform based?
| >I think in .net, you can use DataGrid instead of using
| FlexGrid.
| >Because your checkbox's position was calculated at
| initialization time, you
| >should calculate again when the flexgrid was scrolling.
| >
| >Hope this helps.
| >
| >Best regards,
| >Jeffrey Tan
| >Microsoft Online Partner Support
| >Get Secure! - www.microsoft.com/security
| >This posting is provided "as is" with no warranties and
| confers no rights.
| >
| >--------------------
| >| Content-Class: urn:content-classes:message
| >| From: "VR" <[email protected]>
| >| Sender: "VR" <[email protected]>
| >| Subject: Customizing FlexGrid w/ a check box
| >| Date: Sat, 30 Aug 2003 19:02:42 -0700
| >| Lines: 58
| >| Message-ID: <[email protected]>
| >| MIME-Version: 1.0
| >| Content-Type: text/plain;
| >| charset="iso-8859-1"
| >| Content-Transfer-Encoding: 7bit
| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| >| Thread-Index: AcNvY/alFamRgfAtRmm+AcYFCMvscA==
| >| Newsgroups: microsoft.public.dotnet.languages.csharp
| >| Path: cpmsftngxa06.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.languages.csharp:181086
| >| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
| >| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
| >|
| >| I am trying to embed a check box into a FlexGrid's
| cell,
| >| but having a problem when I start scrolling the grid.
| >|
| >| Here is my MyCheckBox class...
| >|
| >| class MyCheckBox : CheckBox
| >| {
| >| void Init
| >| (
| >| AxMSFlexGridLib.AxMSFlexGrid oGrid,
| >| int iRow,
| >| int iCol
| >| )
| >| {
| >| ...
| >|
| >| this.Name = "GridCheckBox";
| >| this.TabIndex = 3;
| >|
| >| this.Text = "";
| >| this.CheckAlign =
| >| System.Drawing.ContentAlignment.MiddleCenter;
| >|
| >| this.Top = ... // calculate based on iRow, iCol
| >| this.Left = ... // calculate based on iRow, iCol
| >| this.Height = ... // calculate based on iRow, iCol
| >| this.Width = ... // calculate based on iRow, iCol
| >|
| >| oGrid.Controls.Add(this);
| >| }
| >| }
| >|
| >| Whenever I need a checkbox in a grid's cell I create
| one
| >| and add it to the grid:
| >|
| >| class MyGrid : AxMSFlexGridLib.AxMSFlexGrid
| >| {
| >|
| >| void Foo()
| >| {
| >| MyCheckBox oCheckBox = new MyCheckBox();
| >| oCheckBox.Init(this, iRow, iCol);
| >| }
| >| }
| >|
| >| Everything works fine when I create the check box -- it
| >| does appear above the [iRow, iCol] cell, but it gets
| >| shifted as soon as I start scrolling the grid.
| >|
| >| 1. Did I choose the right approach for this?
| >| 2. Do I need to move my check box myself based on what
| >| happens with the grid?
| >| 3. If I do, what is the best approach for it?
| >|
| >| Any suggestions/comments are greatly appreciated!
| >|
| >| Thanks,
| >| VR
| >|
| >
| >.
| >
|

.
 

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

Top