Click here to Skip to main content
15,914,109 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys... ive been trying to look for some code on how to add my own button in a table? let say i have a list view table and inside its cell i want to add my own button and on another column i want it to have images? how will i accomplished that? i know how to do it in java but now that its c# i dont know where to start... do i have to create a class solely for button? and then place it on the table class upon initialization of its content/values? please help me guys... thanks in advance...

By the way i want the table to be place in a window form and not on a webpage or anything...
Posted
Updated 26-Mar-11 20:41pm
v2
Comments
Sandeep Mewara 27-Mar-11 2:52am    
Ok, in short how would you do in Java?

The reason I ask is I guess it should be similar, did you try?
Madzmar25 27-Mar-11 3:19am    
havent tried it in c#... but in java im creating 2 classes..
the 1st one is the class for the table...
the 2nd would be the class extend as JButton and with it an actionlistener...

so on the table class where the getItem() occurs instead of passing a string value im passing a reference of a class that extends as a JButton... i dont really know in c# if it will work and im not really use to coding in c# just yet... i just want a starting point on how to do it and if it were possible... i been searching the net all i can see is a button in a table in asp.net but theres nothing about c#

1 solution

You can use gridview with ItemTemplate
Sample Code:
XML
<asp:GridView ID="GridView1" runat="server">
        <Columns>
        <asp:TemplateField>
        <ItemTemplate>
        <asp:Button runat="server" Text="My Button"  />

        </ItemTemplate></asp:TemplateField>
        </Columns>
        </asp:GridView>
 
Share this answer
 
Comments
Madzmar25 27-Mar-11 3:45am    
it seems to me that this code is for asp.net? are there any way that i can put a button in a gridview or list view using c# in windows form and not on a web page?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900