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

open/savefiledialog name column

3 Answers 68 Views
GridView
This is a migrated thread and some comments may be shown as answers.
superold
Top achievements
Rank 1
superold asked on 11 Dec 2008, 03:20 PM
hi!

i need to replicate the filedialog (vista style) and i cant seem to get the icon of a row to be in the same cell as the text (the Name column in the filedialog contains both an icon and the file name).

How could i mimic this? and coult it be done with an ImageList index istead of an actual Bitmap?

Thanks
-jorge

3 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 12 Dec 2008, 04:20 PM
Hello Jorge Delgado-Lopez,

Thank you for your question. Please see the sample code below:

private void Form1_Load(object sender, EventArgs e) 
        { 
            GridViewDataColumn c = new GridViewDataColumn(); 
            this.radGridView1.Columns.Add(c); 
            for (int i = 0; i < 10; i++) { 
                this.radGridView1.Rows.AddNew(); 
 
        
            } 
             
 
        } 
 
        private void radButton1_Click(object sender, EventArgs e) 
        { 
            
        } 
 
        private void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e) 
        { 
 
            e.CellElement.Image= Image.FromFile("testimage3.jpg"); 
            e.CellElement.Text = "some text"
            e.CellElement.TextImageRelation = TextImageRelation.ImageBeforeText; 
            e.CellElement.ImageLayout = ImageLayout.Center; 
         
        } 

Do not hesitate to write me back if you have more questions.

Kind regards,
Nick
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
superold
Top achievements
Rank 1
answered on 17 Dec 2008, 06:04 PM
thanks. almost there.

The text and image are horizontally center aligned. When the column is wider than the content (image+text) it centers.

How can i horizontal align left?

I have set these properties:

e.CellElement.TextImageRelation = TextImageRelation.ImageBeforeText;
e.CellElement.TextAlignment = ContentAlignment.MiddleLeft;

Thanks,
-j
0
Nick
Telerik team
answered on 18 Dec 2008, 04:48 PM
Hello Jorge Delgado-Lopez,

This will be available for the next Service Pack in January. The code that will work with the upcoming release is the following:

e.CellElement.Image = Image.FromFile("testimage3.jpg"); 
e.CellElement.Text = "some text"
e.CellElement.TextImageRelation = TextImageRelation.ImageBeforeText; 
//ImageLayout has to be set to none: 
e.CellElement.ImageLayout = ImageLayout.None; 
e.CellElement.ImageAlignment = ContentAlignment.MiddleLeft; 
e.CellElement.TextAlignment = ContentAlignment.MiddleLeft; 

Do not hesitate to write me back if you have more questions.

Sincerely yours,
Nick
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
superold
Top achievements
Rank 1
Answers by
Nick
Telerik team
superold
Top achievements
Rank 1
Share this question
or