|
Use FlagsAttribute to make bit fields
[Flags]
public enum States:long
{
B_0000 = 0,
B_0001 = 1,
B_0010 = 2,
B_0100 = 4,
B_1000 = 8
}
DevIntelligence.com - My blog for .Net Developers
|
|
|
|
|
Hi, i try to add data from an Access-database to an ArrayList, so far so good, but something goes wrong, can someone help me...??
public List<cd> cdListe = new List<cd>();
public FyldListe()
{
string dbForbindelse = "provider=Microsoft.Jet.OLEDB.4.0; " + "data
source = C:\\databasenavn.mdb";
string HentAlleData = "SELECT nr, art, model, årgang, navn FROM
oversigt";
OleDbDataAdapter DataAdapter = new OleDbDataAdapter(HentAlleData,
dbForbindelse);
DataSet Datasæt = new DataSet();
DataAdapter.Fill(Datasæt, "oversigt");
DataTable dataTable = Datasæt.Tables[0];
foreach (DataRow dataRow in dataTable.Rows)
{
cdListe.Add(new Kamp(dataRow["nr"], dataRow["art"],
dataRow["model"], dataRow["årgang"]));
}
If i, instead of the last line, write:
listBox1.Items.Add(dataRow["nr"], dataRow["art"], dataRow["model"],
dataRow["årgang"]);
..everything add fine to the listBox.
But the other dosen't work, it say's, that it could not convert from
object to string, and .ToString doesn't help...
what do i do wrong...??
I use visual basic express 2005
(hope u can read my english)
Helge
|
|
|
|
|
I would think it is the Kamp constructor.
I assume the constructor looks something like that:
public Kamp(string nr, string art, srting model, string argang){
}
This means that if you call this constructor you need to pass 4 string parameters, but dataRow["xxx"] returns only an object.
If my constructor assumption is correct you'll need something like that:
cdListe.Add(new Kamp(Convert.ToString(dataRow["nr"]),
Convert.ToString(dataRow["art"]),
Convert.ToString(dataRow["model"]),
Convert.ToString(dataRow["årgang"])));
Duif wrote: I use visual basic express 2005
No you are obviously using Visual C# Express...
|
|
|
|
|
Hi Robert, thank you for the fast reply...,
i will try it immediately...
And of course you are rigth, i use visual studio C# express...
Helge
|
|
|
|
|
Hi Robert, it worked...., i'm happy...
Thank you..., have a nice week-end...
Helge
|
|
|
|
|
Hi again Robert, can you also tell me, how i get the data from the ArrayList added to a DataGridView....???
I thought, that i could do it in the DataGridView properties, datasource...
Helge
|
|
|
|
|
Depends a little bit on how you bound your data but here are two alternatives:
string nr = (string)_entriesGridView[2, 3].Value;
ArrayList list = (ArrayList)_entriesGridView.DataSource;
Kamp kamp = (Kamp)list[2];
string nr = Kamp.Nr;
|
|
|
|
|
Hi
I have created a ListView, with View put to Details.
Added a few items, and gave them some subItems.
Then I changed the background colour on all the
items and subItems.
Then when I click on one item it the background on the
first subitem gets gray, and the other subitems get
a white background.
Is it possible to make all the subitems the same colour,
when the item is selected?
Thanks
QzRz
|
|
|
|
|
In the properties for the ListView control you will see a property named "FullRowSelect". Set this property to true.
-Chris
|
|
|
|
|
It works now
Thanks!
|
|
|
|
|
Is it possible to print your entire form, with pictureboxes etc.
I know you can use ControlPaint.Button etc to print my controls, but what if i had an entire form(not mainmenu and the things above) i wished to output to my printer?
|
|
|
|
|
|
Yes but those examples doesnt really do what i want, it has shortcomings when it comes to pictureboxes etc.
In old vb6.0 you could print an entire form, with PrintForm. MSDN makes an example where they Screenshot the memory for the drawed form(since printform isnt in .net), but if some part of the form is outside the screen, it cant dump that.
To me it sound logically, that you should be able to extract the drawed form somehow, even though it isnt on screen. Perhaps build a shadow of it in memory? and then memcpy that to the printerdocument.
|
|
|
|
|
You could probably have a look at the WM_PRINT and WM_PRINTCLIENT apis. If I remember correctly they nearly did the same thing as WM_PAINT did with the difference not having an invalid area (i.e. outside of the screen).
|
|
|
|
|
Hi
I have created a new Project in VS2003, and added a WindowsForm.
I want the to forms to "communicate". When i call from one to another
I usually create:
public static string/bool/int/etc.
But i want it to do it to:
public static void.
I have done it like this,
public static void Hello()
{
HelloWorld();
}
Where the HelloWorld get data from "private void HelloWorld()"
But that does not work it gives me the error:
'SkoleTing.MainForm.XmlData' denotes a 'field' where a 'class' was expected
I have no clue what I can use instead of the "static", because it is obvious
that I cannot use "static" in this case?
Can anyone help me how to do this?
Thanks
QzRz
|
|
|
|
|
|
Yes, it was exactly what I was looking for
Thanks!
|
|
|
|
|
Hello!
I need to set permissions to some registry keys...
Maybe anyone knows how can I do it?
Thanks!
|
|
|
|
|
|
Good day.
My name is Eugene.
I have a problem with WebBrowser control from .NET FrameWork 2.0 in my project.
My project (C#) is Form with WebBrowser control on it.
I'm loading in WebBrowser other project (ActiveX Document DLL from Visual Studio 6.0):
webBrowser1.navigate("C:\\Test.vbd");
Next, I'm receive the event:
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (webBrowser1.Document != null)
{
// trying get public properties of "Test.vbd" project
}
}
All it's well, but webBrowser1.Document property always equal null.
Although the page loaded correct and event is raising, I can't get access
to the "Test.vbd" interface.
When I use old WebBrowser control (from Visual Studio 6.0) in my C# project,
I get access to "Test.vbd" interface with "pDisp" parameter of event:
void objBrowser_DocumentComplete(object sender, AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
{
SHDocVw.IWebBrowser2 pIBrowser = (SHDocVw.IWebBrowser2)e.pDisp;
...
Can you help me? How can I use new WebBrowser control to get access to "Test.vbd" interface?
Thank you.
-- modified at 8:38 Saturday 17th December, 2005
|
|
|
|
|
Hi Im a beginner and I want to ask maybe a strange question.Please dont judge me...Which is the best book for a fast improvment in C#...Thank you very much.
|
|
|
|
|
|
hi all, do any of you have an idea about the methods that used to generate user id?
i think it is called GUID,,
thank you for any help
marmosha
|
|
|
|
|
marmosha wrote: do any of you have an idea about the methods that used to generate user id?
i think it is called GUID
Well, strictly speaking a GUID is a Globally Unique Identifier rather than just a User ID. Of course, you can use them as user IDs, especially if there are many distributed computers generating the IDs because the algorithm used is supposed to guarantee uniqueness.
See: System.Guid.NewGuid[^]
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
Hi
I have 90 textbox and I want to manage them
their names are finished with two numbers that help me to manage but I cant call them
I should manage them like this
textbox11.hide();
textbox22.hide(); and so on
how can i manage them by their name???
|
|
|
|