|
Why do you need to use reflection ? You know the type, right ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Correct,
I am looking for a way to create a method that will open any form,
the form name will be suppled in a string parameter,
I thoght this is the best way to achive this, can you think of any other way?
Thanks for your attentetion
|
|
|
|
|
belzer wrote: can you think of any other way?
The good news is no one has to think of another way because Creational Patterns[^] have been known and documented for years.
led mike
|
|
|
|
|
If you only know the name as a string, did you get it from reflection ( that is, are you on a bizarre quest to write code that will open any form from any dll ), or is it from a known list ? As someone else said, in the latter case, a Factory pattern is what you want.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
It is from a know list.
To be more specific.
I am building a menu where the menu list is populated form a table that contains the Menu Caption and the Module that should be called on click.
There the long way is where you analyze the menu clicked and then call the corresponding module Like: if menu clicked = A call module x and if menu clicked = B call module y.
But my program may contains about 100 modules and I think the factory pattern will be lots of code lines.
Thanks again
|
|
|
|
|
Writing a project for a client using .NET 3.5 in C#. I need to import data from an XLS spreadsheet into a SQL data table. Problem is, one of the columns in the date table contains an "optional" date field. In the sample file provided by the client, no data exists in that optional field until row 27. The result is that NO ROW contains the optional field in the final SQL table.
I've been using an ODBC connection (MS Jet 4.0) to read the XLS. I tried adding MAXSCANROWS=0, which according to what I've read should allow the first 16384 rows to be used in determining column types. However, this seemed to have no effect.
I read another article that suggested the work-around is registry editing. That's not too practical, especially for deploying this project to the client's server.
Does anyone know another way to get the data to import correctly?
Thanks.
|
|
|
|
|
I've had nightmares trying exactly this kind of thing in Excel. That and the fact that if someone has the file open ODBC doesn't revert to a readonly mode as would happen if 2 people opened an xls file in the conventional manner.
As i remember if the first populated field within a column contains an integer you then get problems if subsequent fields contain text etc.
I think i ended up using the PIA approach and reading the data out cell by cell. It's slightly more laborious but gives a much finer level of control over what is happening
Russ
|
|
|
|
|
PIA approach? Can you point me in the direction of an article that would demonstrate how to read out the data cell by cell? I would have preferred this from the start, but I have been unable to find such information.
Thanks.
|
|
|
|
|
|
Hi, I want to get rid of black arrow in rowheader of DataGridView. Any ideas?
|
|
|
|
|
Set the ShowEditingIcon property to False. I think that's what you are looking for.
|
|
|
|
|
Editing glyph IS NOT the black arrow, showing the row selected! The question is still actual. And I think the solution is to draw in row header. But what exactly? I'm sure somebody had already fixed this issue.
|
|
|
|
|
The one that indicates which row is selected? I haven't yet found a way.
And DataGridViews are for talentless hacks anyway, so I don't bother.
|
|
|
|
|
Have you another decision besides DataGridView to show information in table-style?
|
|
|
|
|
I solved the problem. As my CellPainting has already been overriden, I added such construction to clear the arrow:
using (Brush backColorBrush = new SolidBrush(e.CellStyle.BackColor))
{
e.Graphics.FillRectangle(backColorBrush, e.CellBounds.X+1, e.CellBounds.Y+1, 20,40);
}
|
|
|
|
|
|
|
How to create ".eml" file using desktop application in .net to use it to send E-mail?
|
|
|
|
|
How you create a file, is up to you. What is an eml file ? I have no idea.
You need to know how to send a file via email ? There's tons of articles online that cover this.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Christian Graus wrote: What is an eml file ? I have no idea
Just looked it up in Thunderbird by saving an e-mail in this format. It's basically just the mail header as received from the mail server (from, to, subject, mime, content-type, return-path) and the message body.
I don't see how this can be used to send e-mail.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi, i got a hashtable within a hashtable. How do i retrive the property from the inner hashtable
I got this orderTable which store a Order object.
Inside my Order object, i have a Hashtable itemList as a attributes. The itemList will store a product object which have the property ModelNumber
foreach (Order order in orderTable.Values)
{
if (order.ItemList.ContainsKey(Convert.ToString(p.ModelNumber)))
{
uint modelNum = ((Product)order.ItemList[p.ModelNumber]).ModelNumber;
string cellValue = Convert.ToString(p.ModelNumber);
if (cellValue == Convert.ToString(modelNum))
{
dataGridProduct.Rows[currentRow].Cells["colSelect"].Value = true;
}
}
}
this is what i do, but i get
Object reference not set to an instance of an object.
on this line
uint modelNum = ((Product)order.ItemList[p.ModelNumber]).ModelNumber;
|
|
|
|
|
benjamin yap wrote: order.ItemList[p.ModelNumber]
This, by definition, returns a hashtable, not a Product. That's what you said, right ? That returns a hash table, so you need to pull the value out of that hash table. I am surprised you don't get an invalid cast exception.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
i cast a (Product) infront already and i just do a .ModelNumber
issint this pulling out the value? i tried many ways but cant seems to work. Probably you could help me with it?
|
|
|
|
|
The other response makes sense. I think what you said is wrong, I don't think you have a hashtable of hashtables. I think you're using a bad key, or a key to a value that was stored as null.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Christian Graus wrote: This, by definition, returns a hashtable, not a Product.
I guess ItemList is already the inner hashtable which will, when accessing the indexer, return a Product
regards
modified 12-Sep-18 21:01pm.
|
|
|
|