Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Am I doing the resource access wrong
Message
From
19/07/2007 05:29:34
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
19/07/2007 03:20:19
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01241787
Message ID:
01241792
Views:
25
>This generates no errors, but the cell just shows a red X.
>
>
>    private void OnDataGridViewCellFormat(object sender, DataGridViewCellFormattingEventArgs e)
>      {
>      if (this.dataGridView.Columns[e.ColumnIndex].Name == "imgType")
>        {
>        System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(cdsMessages));
>        int iRow = e.RowIndex;
>        if (cdsMessageDataSet.Messages[iRow].msgtype == "E")
>          {
>          e.Value = ((System.Drawing.Bitmap)(resources.GetObject("Work.bmp")));
>          }
>        else
>          {
>          e.Value = ((System.Drawing.Bitmap)(resources.GetObject("PhoneCall.bmp")));
>          }
>        }
>      }
>
>
>
>I suspect either a wrong argument here:
>
>ResourceManager(typeof(cdsMessages));
>
>or a missing path here:
>
>GetObject("Work.bmp")
>
>But not sure what it should be??
>
>The 2 BMPs are in my Resources folder and marked as Embedded Resource under build action.

John,
Though it looks like a very silly thing to do, looks like ResourceManager.GetObject(string) is doing a case sensitive reflection to find the resource. IOW:
//This might work:
ResourceManager.GetObject("RESOURCE");
//while this one fail:
ResourceManager.GetObject("Resource");
Might not be silly OTOH thinking it creates internal static properties for them.
BTW do not use filename but resource name. ie:
WORK  c:\....\work.bmp
PHONE c:\....\phone.bmp
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform