|
Having everything in a monolithic .EXE file takes the loader forever to load and process, setup the runtime environment (.NET CLR), pass control to the CLR, which reads what it needs, compiles the necessary methods, if not already previously done, and calls the entry point of the code, which will call other methods in the code, and finally getting around to calling InitializeComponent for all of the controls, again, more compiling, and creating an instance of the form.
There's a LOT that happens before you see your startup form...
|
|
|
|
|
Dave Kreskowiak wrote: There's a LOT that happens before you see your startup form
And that's not even all
|
|
|
|
|
Hi
I'm trying to use the system.printing namespace to get the status of print queues on a print server. Unfortunately the only status I ever get for any queue is "None".
Here's the code:
dim myPS as PrintServer = New PrintServer("servername")
dim myPrintQueues as PrintQueueCollection = myPS.GetPrintQueues()
For Each pq as PrintQueue in myPrintQueues
pq.refresh()
'output pq.name
'output pq.QueueStatus.ToString
Next
I must be missing something obvious. Can anyone give me a pointer.
I previously posted this question to the .NET framework forum with no luck so reposting here.
Thanks.
|
|
|
|
|
The code looks good, though I can't test it right now.
There are two possibilities. The user account you're running the code under does have sufficient permissions to get the print queue status, which is unlikely. And, the printer driver is under no obligation to update the status with the print server. So, it's entirely possible that the status really is None, even though it's doing something.
|
|
|
|
|
I've been programming for 5 years and I can't believe something this easy can have me stumped!
I am trying to append the text in a textbox to the next line...
e.g. "This is line 1"
"This is line 2"
"This is line 3", etc.
I set the textbox to accept 'return' and set it to multiline, but whenever I add text to it, it just won't add anything in the next line, they all follow on from the previous line.
I use the chr(13) character to indicate the start of a new line, but that doesn't help either.
My code looks like this:
Dim i As int16
for i = 0 to AdvertList.Rows.Count - 1
'get all the details here...
NewAdvert.AppendText(Chr(13))
NewAdvert.AppendText(advertText)
Next
What am I doing wrong?
Please help?
Thanks in advance
|
|
|
|
|
Myabe try VbCrLf instead of Chr(13)
|
|
|
|
|
Woah, it worked...
You don't have a damp cloth for me to wipe the visible embarrassment from my face?
Took me 40 minutes to write 300 lines of code, and a further 30 minutes trying to get around this simple problem. Damn, I feel so stupid!
Thanks so much for the quick response, saved me a few more wasted minutes of redness.
|
|
|
|
|
No problem, glad I could help someone else for a change instead of other people helping me
|
|
|
|
|
Glad to help my first person on this forum.
|
|
|
|
|
|
I would suggest using Environment.NewLine instead. The vbCrLf constant is platform specific, and a backward-compatiblity holdout from the old VB6 days. There's no guarantee that it will stick around in future versions of the .NET Framework.
|
|
|
|
|
More appropriately, Environment.NewLine .
|
|
|
|
|
Hi, i'm making my first steps into the net framework,i'm making a project
to manage workers formation. I created a sql class and a worker class.
The sql class manages the properties from the database and its actions(connect,create connection strings and so on),the worker class manages the workers properties(names,adress,position and so on).
What i want to do is something like:
Dim Worker2 as new clsWorker(name,age,position)
Dim SqlClient as new ClsSql(ConnectionString,Table)
SqlClient.Addnew(worker)
As i stated before i'm still learning,Since i was a vb6 programmer(Still am ) it confuses me a little OOP,this is piece a cake but i'm not getting there...
Thanks in advance.
|
|
|
|
|
Create a function into your class and return a boolean true when OK or false when not
|
|
|
|
|
I personally would write, read and update the worker details from the worker class and not use a seperate class. Don't know what it was like in VB6 but writing to and reading from a database in .NET doesn't involve very many lines of code so I'm not sure whether you would be gaining much by using a seperate class for database manipulation.
Also, you mention that your SQL class creates connection strings. Your connection strings should be stored in app.config. If your are using Visual Studio this can easily be done through the settings tab of project properties. And then accessed by My.Settings.ConnectionString .
Hope this helps
|
|
|
|
|
Good idea!If i understood Correctly you advise me to 'join' both classes in a maner of speaking. But the problem is i will have more items to work with like the formation they made and that stuff,thats why i thought in making a classe that manipulates sql data otherwise i will have to repeat processes in other classes for instance:
Worker -Properties
-Actions(Add Worker,Update Worker,Delete Worker)
Formation(studies wtv you wanna call it)
-Properties(name,hours,cost)
-Actions(create new,update,delete)
Formation_Workers(assign_to formation,remove from formation)
As you can see i'll have mutiple places to add remove and update data,so i thought having a general sql class would make sense.
|
|
|
|
|
Sure, in an ideal world it would be great not to have to repeat any code whatsoever, but in my (limited) experience, it isn't always possible or practical. I'm sure it would be possible to achieve what you are attempting but for the amount of code you will be saving, it may be more trouble than its worth. Maybe a more experienced developer can other their opinion on this?
Just as an example, here is a snippet of code I use in each class to insert records into a database, as you can see, there isn't really much to it.
Using cnnSQL As New SQL.SqlConnection(My.Settings.ConnectionString)
cnnSQL.Open()
Using cmdSQL As New SQL.SqlCommand(<<stored procedure name>>, cnnSQL)
cmdSQL.CommandType = CommandType.StoredProcedure
With cmdSQL.Parameters
'add parameters here
End With
cmdSQL.ExecuteNonQuery()
End Using
End Using
|
|
|
|
|
I see what you mean.
From what i'm learning by myself and the conclusion that i get to is that one of the advantages of oop is to reutilize the code so you can write less...maybe i'm just taking that to the extreme
|
|
|
|
|
Hi,
I'm using multiple usercontrol, I'm trying to display the usercontrol2
but usercontrol1 is not getting replaced with usercontrol2.
please help me to solve this problem.
|
|
|
|
|
You can't replace a control, but you can create a new one and remove/hide the old. So in your code, create a new usercontorl2, add it to forms controls, place it in the right position and remove the usercontrol1 from forms controls.
If you're using other containers inside the form (for example tabpage), place the control to the right containers controls collection.
|
|
|
|
|
I have added one combobox column to datagrid view in my windows application.
In Combobox items added is 1,2,3,4,5
even the items has been added it doesn't Display anything in my combobox.When i click on arrow of combobox column,it shows added items 1,2,3,4,5
I want atleast one item must be displayed there in combo box by default.
i.e There must be one selected item.
|
|
|
|
|
Set SelectedIndex to other than -1 when you create the column.
Is the column bound?
|
|
|
|
|
first of all thanks for answer darkelv.
For datagridview combobox column there is no selected
index property.
yes it is bound.
I has set displaymember,Valuemember property according to i need it.
|
|
|
|
|
Maybe check if the binding is bound to the correct item/property.
Here's a sample of my code that is bound to an array of enum
Edit: Are you using comboBoxColumn.Items.Add() instead of setting DataSource?
public static AtomDataGridViewComboBoxColumn StatusGridViewColumn(Atom.Interface.ILocale locale)
{
AtomDataGridViewComboBoxColumn status = new AtomDataGridViewComboBoxColumn();
status.DataPropertyName = "Status";
status.HeaderText = LocalText.GetText(locale, LocalID.Create("ChequePrint.Master.Cheque_Status"), "Status");
status.Name = "Status";
status.SortMode = DataGridViewColumnSortMode.Automatic;
status.ReadOnly = false;
status.Width = 90;
status.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
status.DefaultCellStyle.Format = "";
#region .:BE831DCA-BCDC-4294-8634-E33D8C66E51E [Status]:.
ArrayList a = new ArrayList();
a.Add(StatusTypes.Outstanding);
a.Add(StatusTypes.Issued);
a.Add(StatusTypes.Cleared);
a.Add(StatusTypes.Void);
Array enums = a.ToArray(typeof(StatusTypes));
status.DataSource = enums;
#endregion .:BE831DCA-BCDC-4294-8634-E33D8C66E51E [Status]:.
return status;
}
|
|
|
|
|
DataGridViewComboBoxColumn DataGridViewComboBoxCell doesn't have selectedindex or selectedvalue, so you must use Value property instead.
modified on Friday, January 23, 2009 5:05 AM
|
|
|
|