List of buttons

  • Thread starter Thread starter Chuck Douglas
  • Start date Start date
C

Chuck Douglas

I would like to create a custom control which acts like a ListView, but
also contains a list of buttons. The control would have one column of text
values and the second column would contain a button for each corresponding
text value. In my particular example, the button is something the user can
click to set the style associated with the text value. I am trying to
figure out which control in the framework to use to implement such a
control, either by using it directly or deriving from it. Any suggestions?

It seems that the hard part it being able to display a list of custom
buttons, which are user controls themselves. Any help would be appreciated.

Thanks
Chuck
 
Hi Chuck,
IMHO there is no good component that you can use as a base class. The best
is to spend some time and write your one. You might be able to use ListView,
but you have to subclass the native window control in order to intercept
some of its notification messages.

HTH
B\rgds
100
 
Hi Chuck,
How about the Datagrid control? It maybe easy to be customized for your
needs.
You may add a list of buttons by writing a new DataGridColumnStyle class,
you may find an example in,
http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q888q
Ofcourse, because the datagrid works in databinding way, you need to save
the text in a datasource object.

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!

--------------------
| From: "Chuck Douglas" <[email protected]>
| Subject: List of buttons
| Date: Tue, 7 Oct 2003 14:59:49 -0400
| Lines: 16
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| NNTP-Posting-Host: 199.29.3.102
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:53908
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| I would like to create a custom control which acts like a ListView, but
| also contains a list of buttons. The control would have one column of
text
| values and the second column would contain a button for each corresponding
| text value. In my particular example, the button is something the user
can
| click to set the style associated with the text value. I am trying to
| figure out which control in the framework to use to implement such a
| control, either by using it directly or deriving from it. Any
suggestions?
|
| It seems that the hard part it being able to display a list of custom
| buttons, which are user controls themselves. Any help would be
appreciated.
|
| Thanks
| Chuck
|
|
|
|
 
Thanks for you reply. I started playing with the sample that you pointed
me to. I have a couple of questions.

1. My button is a user control which draws it own button face, based on the
style of an object. Would it be possible to use a user control in this
sample?

2. Is there a way to only make the columns of data visible, in the
datagrid? In other words, I do not want to see the leftmost navigation
column with the arrow and *. In my case, I build a dataset and populate it
with fixed data, so I do not want the user to see navigation controls.

Thanks
Chuck
 
Hi Chuck,
it seems possible, you may try show the button in the paint method of
the DatagridColumnStyle,
but we need do some tricks.
first, we should define a button array list to hold the reference, then we
need do lazy initialization
because we must add the buttons to the datagrid.Controls collection in
order to make it visible.
here is a code snippet might help you understand my meaning, but Frankly
it's still a little buggy when scrolling. I'll continue working on it. As
your second question, I think you may take a look at the
DataGridTableStyle.RowHeadersVisible property , setting it to false will
hide the row header.
Thanks!
If you have questions, please let me know!
<code>
//put these code in paint method and comment all others except the parent
variable.
//need to delcare Button[] _btns in the DataGridButtonColumn class.
_btns = new Button[4];
g.FillRectangle(backBrush,bounds);
if(rowNum < _btns.Length)
{
if(_btns[rowNum] == null)
{
_btns[rowNum] = new Button();
_btns[rowNum].BackColor = Color.Pink;
_btns[rowNum].Text = parent[rowNum, _columnNum].ToString();
parent.Controls.Add(_btns[rowNum]);
}
_btns[rowNum].Bounds = bounds;
}
</code>


Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!

--------------------
| From: "Chuck Douglas" <[email protected]>
| References: <[email protected]>
<[email protected]>
| Subject: Re: List of buttons
| Date: Wed, 8 Oct 2003 11:41:46 -0400
| Lines: 79
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
| Message-ID: <Ows#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| NNTP-Posting-Host: 199.29.3.102
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:53962
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| Thanks for you reply. I started playing with the sample that you
pointed
| me to. I have a couple of questions.
|
| 1. My button is a user control which draws it own button face, based on
the
| style of an object. Would it be possible to use a user control in this
| sample?
|
| 2. Is there a way to only make the columns of data visible, in the
| datagrid? In other words, I do not want to see the leftmost navigation
| column with the arrow and *. In my case, I build a dataset and populate
it
| with fixed data, so I do not want the user to see navigation controls.
|
| Thanks
| Chuck
|
| | > Hi Chuck,
| > How about the Datagrid control? It maybe easy to be customized for your
| > needs.
| > You may add a list of buttons by writing a new DataGridColumnStyle
class,
| > you may find an example in,
| > http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q888q
| > Ofcourse, because the datagrid works in databinding way, you need to
save
| > the text in a datasource object.
| >
| > Best regards,
| >
| > Ying-Shen Yu [MSFT]
| > Microsoft Online Partner Support
| > Get Secure! - www.microsoft.com/security
| >
| > This posting is provided "AS IS" with no warranties and confers no
rights.
| > You should not reply this mail directly, "Online" should be removed
before
| > sending, Thanks!
| >
| > --------------------
| > | From: "Chuck Douglas" <[email protected]>
| > | Subject: List of buttons
| > | Date: Tue, 7 Oct 2003 14:59:49 -0400
| > | Lines: 16
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
| > | Message-ID: <[email protected]>
| > | Newsgroups: microsoft.public.dotnet.framework.windowsforms
| > | NNTP-Posting-Host: 199.29.3.102
| > | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
| > | Xref: cpmsftngxa06.phx.gbl
| > microsoft.public.dotnet.framework.windowsforms:53908
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
| > |
| > | I would like to create a custom control which acts like a ListView,
| but
| > | also contains a list of buttons. The control would have one column of
| > text
| > | values and the second column would contain a button for each
| corresponding
| > | text value. In my particular example, the button is something the
user
| > can
| > | click to set the style associated with the text value. I am trying to
| > | figure out which control in the framework to use to implement such a
| > | control, either by using it directly or deriving from it. Any
| > suggestions?
| > |
| > | It seems that the hard part it being able to display a list of
custom
| > | buttons, which are user controls themselves. Any help would be
| > appreciated.
| > |
| > | Thanks
| > | Chuck
| > |
| > |
| > |
| > |
| >
|
|
|
 
Hi Chuck,
sorry, a little mistake in copy paste, the statement
_btns = new Button[4];
should not be here, and should be put in to the constructor of the
DataGridButtonColumn class.


Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!

--------------------
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| From: (e-mail address removed) (Ying-Shen Yu[MSFT])
| Organization: Microsoft
| Date: Thu, 09 Oct 2003 03:52:25 GMT
| Subject: Re: List of buttons
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
|
| Hi Chuck,
| it seems possible, you may try show the button in the paint method
of
| the DatagridColumnStyle,
| but we need do some tricks.
| first, we should define a button array list to hold the reference, then
we
| need do lazy initialization
| because we must add the buttons to the datagrid.Controls collection in
| order to make it visible.
| here is a code snippet might help you understand my meaning, but Frankly
| it's still a little buggy when scrolling. I'll continue working on it. As
| your second question, I think you may take a look at the
| DataGridTableStyle.RowHeadersVisible property , setting it to false will
| hide the row header.
| Thanks!
| If you have questions, please let me know!
| <code>
| //put these code in paint method and comment all others except the parent
| variable.
| //need to delcare Button[] _btns in the DataGridButtonColumn class.
| _btns = new Button[4];
| g.FillRectangle(backBrush,bounds);
| if(rowNum < _btns.Length)
| {
| if(_btns[rowNum] == null)
| {
| _btns[rowNum] = new Button();
| _btns[rowNum].BackColor = Color.Pink;
| _btns[rowNum].Text = parent[rowNum, _columnNum].ToString();
| parent.Controls.Add(_btns[rowNum]);
| }
| _btns[rowNum].Bounds = bounds;
| }
| </code>
|
|
| Best regards,
|
| Ying-Shen Yu [MSFT]
| Microsoft Online Partner Support
| Get Secure! - www.microsoft.com/security
|
| This posting is provided "AS IS" with no warranties and confers no rights.
| You should not reply this mail directly, "Online" should be removed
before
| sending, Thanks!
|
| --------------------
| | From: "Chuck Douglas" <[email protected]>
| | References: <[email protected]>
| <[email protected]>
| | Subject: Re: List of buttons
| | Date: Wed, 8 Oct 2003 11:41:46 -0400
| | Lines: 79
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
| | Message-ID: <Ows#[email protected]>
| | Newsgroups: microsoft.public.dotnet.framework.windowsforms
| | NNTP-Posting-Host: 199.29.3.102
| | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| | Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.framework.windowsforms:53962
| | X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
| |
| | Thanks for you reply. I started playing with the sample that you
| pointed
| | me to. I have a couple of questions.
| |
| | 1. My button is a user control which draws it own button face, based
on
| the
| | style of an object. Would it be possible to use a user control in this
| | sample?
| |
| | 2. Is there a way to only make the columns of data visible, in the
| | datagrid? In other words, I do not want to see the leftmost navigation
| | column with the arrow and *. In my case, I build a dataset and
populate
| it
| | with fixed data, so I do not want the user to see navigation controls.
| |
| | Thanks
| | Chuck
| |
| | | | > Hi Chuck,
| | > How about the Datagrid control? It maybe easy to be customized for
your
| | > needs.
| | > You may add a list of buttons by writing a new DataGridColumnStyle
| class,
| | > you may find an example in,
| | > http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q888q
| | > Ofcourse, because the datagrid works in databinding way, you need to
| save
| | > the text in a datasource object.
| | >
| | > Best regards,
| | >
| | > Ying-Shen Yu [MSFT]
| | > Microsoft Online Partner Support
| | > Get Secure! - www.microsoft.com/security
| | >
| | > This posting is provided "AS IS" with no warranties and confers no
| rights.
| | > You should not reply this mail directly, "Online" should be removed
| before
| | > sending, Thanks!
| | >
| | > --------------------
| | > | From: "Chuck Douglas" <[email protected]>
| | > | Subject: List of buttons
| | > | Date: Tue, 7 Oct 2003 14:59:49 -0400
| | > | Lines: 16
| | > | X-Priority: 3
| | > | X-MSMail-Priority: Normal
| | > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
| | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
| | > | Message-ID: <[email protected]>
| | > | Newsgroups: microsoft.public.dotnet.framework.windowsforms
| | > | NNTP-Posting-Host: 199.29.3.102
| | > | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
| | > | Xref: cpmsftngxa06.phx.gbl
| | > microsoft.public.dotnet.framework.windowsforms:53908
| | > | X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
| | > |
| | > | I would like to create a custom control which acts like a
ListView,
| | but
| | > | also contains a list of buttons. The control would have one column
of
| | > text
| | > | values and the second column would contain a button for each
| | corresponding
| | > | text value. In my particular example, the button is something the
| user
| | > can
| | > | click to set the style associated with the text value. I am trying
to
| | > | figure out which control in the framework to use to implement such a
| | > | control, either by using it directly or deriving from it. Any
| | > suggestions?
| | > |
| | > | It seems that the hard part it being able to display a list of
| custom
| | > | buttons, which are user controls themselves. Any help would be
| | > appreciated.
| | > |
| | > | Thanks
| | > | Chuck
| | > |
| | > |
| | > |
| | > |
| | >
| |
| |
| |
|
 
Back
Top