This is a migrated thread and some comments may be shown as answers.

Adding Image to commandColumn

3 Answers 81 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Timotei
Top achievements
Rank 1
Timotei asked on 28 Feb 2009, 07:24 PM
I have a table like this:


<name 1>  <checkbox>  <button>
<name 2>  <checkbox>  <button>
<name 3>  <checkbox>  <button>
...
<name n>  <checkbox>  <button>

So basically with this form will be the gridView (i will add them programatically not by binding to a source)

So the question arrives here:

I use:

radGridView1.Rows.Add("name 1",true , "run");

and so on.

How can i add an image to the button? i mean to the commandCollumn? Cause i need to have the same image on each button.

PS: and also how can i add a custom structure like this:

public class MyClass{ 
  string name;

public override ToString(){
return name;
}
}

To put it instead that single text?

Thanks a lot ;)
Timotei

3 Answers, 1 is accepted

Sort by
0
Timotei
Top achievements
Rank 1
answered on 01 Mar 2009, 04:26 PM
It's ok with the custom structure... i figured it out... But it remains that image problem
0
Timotei
Top achievements
Rank 1
answered on 01 Mar 2009, 04:31 PM
I found the answer to my initial question too. Thanks a lot (http://www.telerik.com/community/forums/winforms/gridview/image-for-command-button.aspx)

As for my second question here is the answer, maybe someone wants to know how i did:
This is the custom class used for replacement:
public class CustomTextColumn<T> : Telerik.WinControls.UI.GridViewTextBoxColumn 
    { 
        public T CustomStruct; 
 
        public CustomTextColumn() 
            : base() 
        { 
            this.DataType = typeof(T); 
            this.ImageLayout = System.Windows.Forms.ImageLayout.Center; 
        } 
        public CustomTextColumn(string uniqueName, string fieldName, T str) 
            : base(uniqueName, fieldName) 
        { 
            this.DataType = typeof(T); 
            CustomStruct = str; 
        } 
    } 


And i will replace in designer.cs the collumn:
Telerik.WinControls.Ui.GridViewTextBoxColumn with: CustomTextColumn<MyStruct>

Bye!
0
Martin Vasilev
Telerik team
answered on 03 Mar 2009, 07:39 AM
Hi Timoootei,

I am glad that you have found the answers to your questions and solved the problems. Thank you for sharing your solution.

Do not hesitate to contact us again if you have other questions.

All the best,
Martin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Timotei
Top achievements
Rank 1
Answers by
Timotei
Top achievements
Rank 1
Martin Vasilev
Telerik team
Share this question
or