Click here to Skip to main content
15,918,471 members
Home / Discussions / C#
   

C#

 
GeneralRe: About Threading Pin
Dario Solera13-Aug-06 22:27
Dario Solera13-Aug-06 22:27 
AnswerRe: About Threading Pin
CooperWu13-Aug-06 21:41
CooperWu13-Aug-06 21:41 
Questionsort and filter a set of database Pin
skyeddie13-Aug-06 19:50
skyeddie13-Aug-06 19:50 
AnswerRe: sort and filter a set of database Pin
leppie13-Aug-06 22:14
leppie13-Aug-06 22:14 
QuestionPassing an [in] parameter to an asp.net web service Pin
Mehdi Mousavi13-Aug-06 19:15
Mehdi Mousavi13-Aug-06 19:15 
AnswerRe: Passing an [in] parameter to an asp.net web service Pin
leppie13-Aug-06 21:54
leppie13-Aug-06 21:54 
GeneralRe: Passing an [in] parameter to an asp.net web service Pin
Mehdi Mousavi14-Aug-06 0:32
Mehdi Mousavi14-Aug-06 0:32 
QuestionDisplay Image in a Datagrid Pin
Rabbit1713-Aug-06 18:51
Rabbit1713-Aug-06 18:51 
Okay, I've tinkered with this code and have not been able to get an image to display:
http://www.codeguru.com/Csharp/Csharp/cs_controls/datagrid/article.php/c4783/#more[^]

Basically, I am designing a drag and drop where I create a thumbnail for each image dragged and put that image into a table. I want everything in one row so I create a column for each image dragged. Then I create a new GridTableStyle for each new column. Then I set the DataSource. I'd like to do this with the use of a dataset, but I not picky just so long as I can get it to work.

So far all I get is a big white box with a giant Red "X" through it. Anyone have any ideas? Thanks in advance!

Here is my code:

public void ImageLoader()
{
//Create Thumbnails
foreach(string fn in files)
{
try
{
ImageConverter(fn);
}
catch(Exception)
{
}
}
//ids is Image-DataSet
ids.Tables.Add(dt);

getGridTableStyle();

image_Datagrid.TableStyles.Add(DGStyle);

image_Datagrid.DataSource = ids;

image_Datagrid.DataMember = dt.TableName;
}

private void ImageConverter(string filename)
{
string imageFile = Path.GetFileNameWithoutExtension(lastFilename).ToLower();
//Create and Save the Thumbnail and return the image
Image img = CreateThumbnail(filename);

//Put the image in the DataTable and name the column the image name without
//extension or directory info i.e. 'c:\\test.bmp' uses 'test' as the column name
AddThumbnailToDataTable(img, imageFile);
}

private void AddThumbnailToDataTable(Image img2, string columnName)
{
dt.BeginLoadData();
this.dt.Columns.Add(columnName);
this.dt.Rows[0][columnName] = (Bitmap)img2;
dt.EndLoadData();
}

private void getGridTableStyle()
{
try
{
DataGridColumnStyle GridTextColumn, GridBmpColumn;
DGStyle = new DataGridTableStyle();

// select table
DGStyle.MappingName = "Images";

// Use a PropertyDescriptor to create a formatted column. First get the PropertyDescriptorCollection
// for the data source and data member.
PropertyDescriptorCollection pcol = form1.BindingContext[ids, dt.TableName].GetItemProperties();

// create the first column style for a text column
GridTextColumn = new DataGridTextBoxColumn(pcol["ImageInfo"]);
GridTextColumn.MappingName = "ImageInfo";
GridTextColumn.HeaderText = "Image-Name";
GridTextColumn.Width = 50;
DGStyle.GridColumnStyles.Add(GridTextColumn);

//Create an ImageColumn for each image in the table
for(int i = 1; i < dt.Columns.Count; i++)
{

// create column style for an image column
GridBmpColumn = new DataGridImageColumn(pcol[dt.Columns[i].ColumnName]);
GridBmpColumn.MappingName = dt.Columns[i].ColumnName;
GridBmpColumn.HeaderText = "Bitmap";
GridBmpColumn.Width = 80;
DGStyle.GridColumnStyles.Add(GridBmpColumn);
}

DGStyle.RowHeadersVisible = false;
}
catch(Exception e)
{
MessageBox.Show(e.Message, "Adding Images to Grid TableStyle");
}

}

Thanks!
RABB17
AnswerRe: Display Image in a Datagrid Pin
Rabbit1714-Aug-06 11:39
Rabbit1714-Aug-06 11:39 
QuestionIE login Pin
Archyami13-Aug-06 18:30
Archyami13-Aug-06 18:30 
AnswerRe: IE login Pin
leppie13-Aug-06 22:03
leppie13-Aug-06 22:03 
GeneralRe: IE login Pin
Archyami13-Aug-06 22:20
Archyami13-Aug-06 22:20 
GeneralRe: IE login Pin
leppie13-Aug-06 22:25
leppie13-Aug-06 22:25 
GeneralRe: IE login Pin
Archyami13-Aug-06 22:27
Archyami13-Aug-06 22:27 
GeneralRe: IE login Pin
Guffa13-Aug-06 23:18
Guffa13-Aug-06 23:18 
GeneralRe: IE login Pin
Archyami13-Aug-06 23:35
Archyami13-Aug-06 23:35 
AnswerRe: IE login Pin
Archyami13-Aug-06 23:45
Archyami13-Aug-06 23:45 
Questionpassword Pin
skyeddie13-Aug-06 17:17
skyeddie13-Aug-06 17:17 
AnswerRe: password Pin
Christian Graus13-Aug-06 18:47
protectorChristian Graus13-Aug-06 18:47 
GeneralRe: password Pin
skyeddie13-Aug-06 19:22
skyeddie13-Aug-06 19:22 
GeneralRe: password Pin
Christian Graus13-Aug-06 19:39
protectorChristian Graus13-Aug-06 19:39 
Question.Net CheckedComboBox. Pin
Automation Software Engineer (A.S.E)13-Aug-06 16:54
Automation Software Engineer (A.S.E)13-Aug-06 16:54 
AnswerRe: .Net CheckedComboBox. Pin
Automation Software Engineer (A.S.E)26-Aug-06 7:48
Automation Software Engineer (A.S.E)26-Aug-06 7:48 
QuestionProgram works when using a breakpoint but not otherwise Pin
Glen Harvy13-Aug-06 14:41
Glen Harvy13-Aug-06 14:41 
AnswerRe: Program works when using a breakpoint but not otherwise Pin
Christian Graus13-Aug-06 14:48
protectorChristian Graus13-Aug-06 14:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.