Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
BizarroAzrael
Apr 6, 2006

"That must weigh heavily on your soul. Let me purge it for you."

Sprawl posted:

Well the user on that machine had permission to write to the registry i assume? is UAC on?

What os and is it different then the one your testing on?

The machine is very similar to the one I made the app on, and has admin privileges. I'm going to need to deploy it to machines without admin though, will that be a problem?

Adbot
ADBOT LOVES YOU

wwqd1123
Mar 3, 2003
if I have a base class with 3 constructors like this:

code:
public Class(int a){...

public Class(int a, int b){...

public class(int a, int b, inc c){...
Then I have a new class that inherits from this base class do I really have to do this?

code:
public Class(int a):base(a){...

public Class(int a, int b):base(a,b){...

public class(int a, int b, inc c):base(a,b,c){...
Or is there an easier way with less typing?

Sprawl
Nov 21, 2005


I'm a huge retarded sperglord who can't spell, but Starfleet Dental would still take me and I love them for it!
wouldn't a partial class make more sense? or if they are classes can't you just inhert the class?

Sprawl fucked around with this message at 07:21 on Apr 20, 2010

dwazegek
Feb 11, 2005

WE CAN USE THIS :byodood:

wwqd1123 posted:

if I have a base class with 3 constructors like this:

Then I have a new class that inherits from this base class do I really have to do this?

Or is there an easier way with less typing?

Yep, you'll have to write out any constructors you want to use. As far as I can tell VS doesn't have an auto-generate option either, although the new addition of optional parameters could cut down on the number of overloads you have to write.


BizarroAzrael posted:

The machine is very similar to the one I made the app on, and has admin privileges. I'm going to need to deploy it to machines without admin though, will that be a problem?

Depends on which registry hive you're writing to, CurrentUser will work just fine, I'm not sure about AllUsers (or whatever it's called), the rest require admin privileges.

dwazegek fucked around with this message at 08:31 on Apr 20, 2010

roflsaurus
Jun 5, 2004

GAOooooooh!! RAOR!!!
Anyone have any experience with a NoSQL database like CouchDB or MongoDB?

I'm working on a document-centric project (kinda ecm'ish), and it looks appealing. The caveat being that I'll need to store other information about the documents in a normal MSSQL db (e.g. viewing histories).

mantralord
Apr 28, 2004
I have a list of objects in C#, with each one storing the time it was created, which is checked periodically by a function, and the function removing the object from the list if it's too old. I've searched for an answer to this, but most examples of measuring elapsed time say to store a DateTime.Now.Ticks or whatever, and comparing it to another DateTime.Now, but I'm worried about that being thrown off if the user changes the system time during that period. Another option is Environment.TickCount, but that's only an int value which wraps around after a month or so, and my program could have uptimes larger than that. The best option I've seen is to use a StopWatch, but that class seems more geared towards measuring performance than for general use. In C, I would just store a clock_t and compare it with clock(), but I can't find an equivalent in C#. What's the best thing to do in this scenario?

PhonyMcRingRing
Jun 6, 2002
Does anyone know of a way to detect if a user is currently logged in through remote desktop? I'm working on a WPF application where I'd like to disable animations if the user's logged in through remote desktop(cause the animations look like crap).

Sprawl
Nov 21, 2005


I'm a huge retarded sperglord who can't spell, but Starfleet Dental would still take me and I love them for it!

PhonyMcRingRing posted:

Does anyone know of a way to detect if a user is currently logged in through remote desktop? I'm working on a WPF application where I'd like to disable animations if the user's logged in through remote desktop(cause the animations look like crap).

C# syntax

public static bool IsRemoteSession { get; }

http://msdn.microsoft.com/en-us/library/system.windows.systemparameters.isremotesession(VS.85).aspx

PhonyMcRingRing
Jun 6, 2002

Sprawl posted:

C# syntax

public static bool IsRemoteSession { get; }

http://msdn.microsoft.com/en-us/library/system.windows.systemparameters.isremotesession(VS.85).aspx

Ha! I love you, thanks!

DigitalDud
Sep 6, 2005

mantralord posted:

I have a list of objects in C#, with each one storing the time it was created, which is checked periodically by a function, and the function removing the object from the list if it's too old. I've searched for an answer to this, but most examples of measuring elapsed time say to store a DateTime.Now.Ticks or whatever, and comparing it to another DateTime.Now, but I'm worried about that being thrown off if the user changes the system time during that period. Another option is Environment.TickCount, but that's only an int value which wraps around after a month or so, and my program could have uptimes larger than that. The best option I've seen is to use a StopWatch, but that class seems more geared towards measuring performance than for general use. In C, I would just store a clock_t and compare it with clock(), but I can't find an equivalent in C#. What's the best thing to do in this scenario?

I think Stopwatch is your best option, it's designed for measuring elapsed time, and uses 64-bit counters. It doesn't have to be used for just profiling.

gwar3k1
Jan 10, 2005

Someday soon
This is going to be incredibly easy but Google returns information for MDI forms which (I don't think) isn't applicable to my problem.

I have a master form. It creates a single note form on load, and the note can create more notes by calling the AddNote function of the parent.

I'm having trouble setting Form1 as the parent though. When I try, I get the error:

quote:

Top-level control cannot be added to a control.

I'm able to access the code of the "parent" so why can't I define it as the parent?

code:
public void AddNote()
        {
            frmNote NewNote = new frmNote(this);
            NewNote.Show();
            NewNote.Parent = this; // Causing the error
            MessageBox.Show(this.HasChildren.ToString()); // Returns false
        }
I realise this must be Forms 101 but I've failed in working it out and googling a solution.

dwazegek
Feb 11, 2005

WE CAN USE THIS :byodood:
Apparently you can't put a Form (a top-level control) on another Control, which makes sense.

You probably want NewNote.Show(this), this sets the current form as the Owner of the form.

gwar3k1
Jan 10, 2005

Someday soon

dwazegek posted:

Apparently you can't put a Form (a top-level control) on another Control, which makes sense.

You probably want NewNote.Show(this), this sets the current form as the Owner of the form.

Ah, so forms in general can't be parents of other forms? How does that make sense? It's not self referential, the form1 that created a new instance of the frmNote form should be able to be the parent of the class it created, surely? Whats the distinction between ownership and parentage?

Thank you. I set frmNote.Owner to Form1 and now I can do what I want (establish how many instances of frmNote there is) by using this.OwnedForms.

dwazegek
Feb 11, 2005

WE CAN USE THIS :byodood:
Child controls actually lay on their parent and can never be drawn outside of the bounds of their parent.

Owned forms can be drawn outside of their owner, they just always appear in front of their owner, and are hidden/closed with their owner.

There's probably also a distinction at the underlying win32 HWND level, but I'm not familiar enough with that to comment.

gwar3k1
Jan 10, 2005

Someday soon

dwazegek posted:

Child controls actually lay on their parent and can never be drawn outside of the bounds of their parent.

Owned forms can be drawn outside of their owner, they just always appear in front of their owner, and are hidden/closed with their owner.

There's probably also a distinction at the underlying win32 HWND level, but I'm not familiar enough with that to comment.

Thanks a lot. In that case I'm glad I came for help as I want to be able to move the extra forms around the screen but the initial form will be really small.

Arms_Akimbo
Sep 29, 2006

It's so damn...literal.
This is probably a really easy question, I just can't seem to wrap my head around this particular cast in C#

code:
string[] foo = (string[])arraylist.ToArray(typeof(string));
It seems to me that the last part of that statement states that you're going to take an ArrayList, and convert it to a string[]. Why does it still need to be cast as a string[]? Is there a simple explanation for this?

ljw1004
Jan 18, 2005

rum

Arms_Akimbo posted:

Why does it still need to be cast as a string[]? Is there a simple explanation for this?

The compiler doesn't have privileged information about the ToArray(typeof(string)) function. In particular, the compiler doesn't know that it will return a string[]. For all it knows, the function might even return an int[] !

We as humans know that the function will return a string[]. The cast in your code is the way that we can tell the compiler what we know.

code:
var s = arraylist.ToArray(typeof(string));
// hover over "var". The compiler has inferred System.Array as the type of t.
        
var t = arraylist.Cast<string>().ToArray();
// hover over "var". The compiler has inferred string[] as the type of t.
This "t" version is another way of doing it, although less efficient I imagine.

Arms_Akimbo
Sep 29, 2006

It's so damn...literal.
Ah ok, that makes a lot of sense. Thanks.

IcedPee
Jan 11, 2008

Yarrrr! I be here to plunder the fun outta me workplace! Avast!

FREE DECAHEDRON!
Having a weird WPF problem.

Different versions of windows have different themes in WPF. This causes some of my controls to be pushed out of a window in Vista that is appropriately sized in XP. What I'm trying to do is apply a template to each window that sets the values (font size seems to be the biggest culprit) in a consistent way over all versions of windows.

So what I've done is opened expression blend and modified the template for a window. I had it add in a font size, and this is what I get in my app.xaml :

code:
<Application.Resources>
		<!-- Resources scoped at the Application level should be defined here. -->
		<ControlTemplate x:Key="WindowTemplateKey" TargetType="{x:Type Window}">
			<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" 
                         BorderThickness="{TemplateBinding BorderThickness}">
				<Grid>
					<AdornerDecorator>
						<ContentPresenter/>
					</AdornerDecorator>
					<ResizeGrip x:Name="WindowResizeGrip" HorizontalAlignment="Right" 
                                         VerticalAlignment="Bottom" IsTabStop="false" Visibility="Collapsed"/>
				</Grid>
			</Border>
			<ControlTemplate.Triggers>
				<MultiTrigger>
					<MultiTrigger.Conditions>
						<Condition Property="ResizeMode" Value="CanResizeWithGrip"/>
						<Condition Property="WindowState" Value="Normal"/>
					</MultiTrigger.Conditions>
					<Setter Property="Visibility" TargetName="WindowResizeGrip" Value="Visible"/>
				</MultiTrigger>
			</ControlTemplate.Triggers>
		</ControlTemplate>
		<Style TargetType="{x:Type Window}">
			<Setter Property="Foreground" 
                         Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/>
			<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
			
			<Setter Property="Template">			
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type Window}">
						<Border Background="{TemplateBinding Background}" 
                                                 BorderBrush="{TemplateBinding BorderBrush}"
                                                 BorderThickness="{TemplateBinding BorderThickness}">
							<AdornerDecorator>
								<ContentPresenter/>
							</AdornerDecorator>
						</Border>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
			<Setter Property="FontSize" Value="11"/>
			<Style.Triggers>
				<Trigger Property="ResizeMode" Value="CanResizeWithGrip">
					<Setter Property="Template" Value="{StaticResource WindowTemplateKey}"/>
				</Trigger>
			</Style.Triggers>
		</Style>
	</Application.Resources>
I then apply that template to the window.

code:
<Window
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	x:Class="WpfApplication1.MainWindow"
	x:Name="Window"
	Title="MainWindow"
	Width="640" Height="480" 
	Template="{DynamicResource WindowTemplateKey}">

	<Grid x:Name="LayoutRoot">
		<Label Content="Text!" />
	</Grid>
</Window>
Everything looks good in the blend designer. Unfortunately when I run my app, it completely ignores the template and puts in whatever the hell font size it wants (in XP - haven't tested this in Vista yet). If I explicitly set the font size in the window tag instead, it works exactly how I want it to.

This is all auto-gen code I'm using, so I'm really not sure what's going on here. Anyone else have this problem?


edit: wow, that's some severe table-breaking. Added line breaks.

IcedPee fucked around with this message at 15:45 on Apr 23, 2010

BliShem
Dec 21, 2008
Ir doesn't look like you even need to apply your template - your font size settings are in the default window style, not in the template itself, and the style loads the template you want automatically anyway.

I think the whole thing doesn't work because the default style isn't applying automatically to your window since its the wrong type.

Add this attribute in the root of the App.xaml file:
code:
xmlns:local="clr-namespace:WpfApplication1"
Then change all the
code:
TargetType="{x:Type Window}"
to
code:
TargetType="{x:Type local:MainWindow}"
This should make the font settings in the style apply.

IcedPee
Jan 11, 2008

Yarrrr! I be here to plunder the fun outta me workplace! Avast!

FREE DECAHEDRON!
Ok, that's fixed the problem, but it raises another one: I'd like to apply this same style to _all_ windows and not just MainWindow. What am I doing wrong?

Edit: nevermind, I've got it now. I didn't see the part about the templates.

IcedPee fucked around with this message at 20:41 on Apr 23, 2010

BliShem
Dec 21, 2008

IcedPee posted:

Ok, that's fixed the problem, but it raises another one: I'd like to apply this same style to _all_ windows and not just MainWindow. What am I doing wrong?

Ok then, put back the TargetType as it was before, and add
code:
x:Key="MyStyle"
to the Style definition.

Then add
code:
Style="{DynamicResource MyStyle}"
to each window.

thehandtruck
Mar 5, 2006

the thing about the jews is,
I'm having trouble with arrays, lots of trouble. Like, been pulling my hair out for 6 hours trouble. For some reason I got the Alpha subprocedure to work, and the newCust to work ("work" in this case meaning not give me compiling errors, I wonder if they'll *actually* work) but the sub Search and printPerson are giving me a hard time. I would really appreciate if somebody could look over the following code and point me in the right direction.

code:
'Program Description: program to run a modified hotel resreveration system with customers names, etc
    Structure Customer
        Dim CustName As String
        Dim StartDate As String
        Dim LengthStay As Integer
        Dim Room As Integer
        Dim Bill As Double
    End Structure
    Private Sub btnDoSomething_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDoSomething.Click
        'main program
        'determine file to read
        Dim filename As String
        OpenFileDialog1.ShowDialog()
        OpenFileDialog1.InitialDirectory = "c:\"
        OpenFileDialog1.Filter = "Text Documents (*.TXT)|*.TXT"
        OpenFileDialog1.FilterIndex = 1
        OpenFileDialog1.RestoreDirectory = True
        MsgBox("You selected " & OpenFileDialog1.FileName)
        filename = OpenFileDialog1.FileName
        'main program

        Dim Cust(40) As Customer

        'fill up the array

        Call LoadArray(filename, Cust)

        'dteremine which checkboxes were checked
        If chkAlphabetize.Checked = True Then Call Alpha(Cust)
        If chkAddCustomer.Checked = True Then Call newCust(Cust)
        'If chkSearch.Checked = True Then Call Search(custname)



        'if alphatize checkeboxes checked, sort ascending or descending
        'etc add more specific algorithym for each box after checkbox sub is created
  


    End Sub
    Sub newCust(ByRef Cust() As Customer)
        'description:adds a new customer to the array
        'input:custoimer name, length of stay, type of room, etc
        'output: the new customer and his/her information back into main program
        'resize the array, so there'[s blank spot at bototm of araay
        Dim index As Integer = Cust.GetUpperBound(0)
        ReDim Preserve Cust(index + 1)
        Cust(index + 1).CustName = InputBox("Enter name of Customer: <First Last>", _
                                            "Enter Name", "w")
        'may need to fix the name
        'add more input boxes, still need room type, nights staying, etc
        'calc their bill
        'Call PrintHeader()
        Call Alpha(Cust) 'cause alphabetaizeze subproduced has print array in it
    End Sub
    Sub Alpha(ByRef Cust() As Customer)
        'description: alphabetizes and sorts the output
        'input: cust
        'output:none
        'can modify this code for the sort by amount billed
        For pass As Integer = 1 To Cust.GetUpperBound(0) - 1
            For compare As Integer = 0 To Cust.GetUpperBound(0) - 1
                If Cust(compare).CustName.ToUpper > Cust(compare + 1).CustName.ToUpper Then
                    'perform a swap operation
                    Call swap(Cust(compare), Cust(compare + 1))
                End If
            Next
        Next
        'prin the sorted array
        'Call PrintArrays(Cust)
    End Sub
    Sub LoadArray(ByVal filename As String, ByRef Cust() As Customer)
        'description: filling up the array
        'inpout: taking 2 items as input, filename and list of customers as an array
        'output: sending the completed array back to the main program
        Dim counter As Integer = 0
        Dim line As String
        'open the file
        Dim sr As IO.StreamReader = IO.File.OpenText(filename)

        'begin the loop
        Do While sr.Peek <> -1
            'read from file
            line = sr.ReadLine
            'breka the line into smaller pieces
            Call parseLine(line, Cust, counter)
            counter += 1
        Loop
        'shrink the array bac kdown to the right size
        ReDim Preserve Cust(counter - 1)
        sr.Close()
    End Sub
    Sub printPerson(ByVal CustName() As Customer)
        'description:  'Print the customers and their bill
        'input: cust name, bill, lenght of stay
        'output: none
        Dim fmtStr As String = "{0, -20}{1, 15:C}"
        lstDisplay.Items.Add(String.Format(fmtStr, CustName))
    End Sub
End Class
Notice how I had to comment out some 'Call' lines because they wouldn't compile. I've tried every combination and even looked at my previous programs but it doesn't to work. I can declare it, but then it screws up the Cust array. What a mess.

thehandtruck fucked around with this message at 22:01 on Sep 12, 2011

ljw1004
Jan 18, 2005

rum

thehandtruck posted:

I'm having trouble with arrays, lots of trouble. I would really appreciate if somebody could look over the following code and point me in the right direction.

Well, here are some functions that will work:

code:
    Sub printPerson(ByVal CustName() As Customer)
        'description:  'Print the customers and their bill
        'input: cust name, bill, lenght of stay
        'output: none
        Dim fmtStr As String = "{0, -20}{1, 15:C}"
        For Each Customer In CustName
            lstDisplay.Items.Add(String.Format(fmtStr, Customer.CustName, Customer.Bill))
        Next
    End Sub

    Sub Search(ByVal Cust() As Customer)
        Dim name = InputBox("Name of customer")
        Dim matches = From c In Cust Where c.CustName Like name
        lstDisplay.Items.Clear()
        printPerson(matches.ToArray)
    End Sub
But your code made my head hurt. Here's another way of doing it.

code:
Option Strict On

Public Class Form1

    'Program Description: program to run a modified hotel resreveration system with customers names, etc
    Class Customer
        Public CustName As String
        Public StartDate As String
        Public LengthStay As Integer
        Public Room As Integer
        Public Bill As Double

        Public Overrides Function ToString() As String
            Return String.Format("{0, -20}{1, 15:C}", CustName, Bill)
        End Function
    End Class

    Dim Customers As New SortedList(Of String, Customer)

    Function parseLine(ByVal line As String) As Customer
        Return New Customer With {.CustName = line, .StartDate = "today", .LengthStay = 3, .Room = 101, .Bill = 102.5}
    End Function

    Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click
        OpenFileDialog1.ShowDialog()
        OpenFileDialog1.InitialDirectory = "c:\"
        OpenFileDialog1.Filter = "Text Documents (*.TXT)|*.TXT"
        OpenFileDialog1.FilterIndex = 1
        OpenFileDialog1.RestoreDirectory = True

        Dim lines = My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName).
            Split({vbCrLf, vbCr, vbLf}, StringSplitOptions.RemoveEmptyEntries)

        Customers.Clear()
        For Each line In lines
            Dim customer = parseLine(line)
            Customers.Add(customer.CustName, customer)
        Next
        ShowCustomers(Customers.Values)
    End Sub

    Sub ShowCustomers(ByVal cc As IEnumerable(Of Customer))
        lstDisplay.Items.Clear()
        lstDisplay.Items.AddRange(cc.ToArray())
    End Sub

    Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        Dim name = InputBox("Enter name of Customer: <First Last>", "Enter Name", "John Doe")
        Dim customer = New Customer With {.CustName = name}
        Customers.Add(customer.CustName, customer)
        ShowCustomers(Customers.Values)
    End Sub

    Private Sub txtFilter_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtFilter.TextChanged
        Dim matches = From c In Customers.Values Where c.CustName.Contains(txtFilter.Text)
        ShowCustomers(matches)
    End Sub
End Class
Edit: some of this code uses new features from VS2010. If you're using an older version, then it needs this instead:

code:
Dim lines = My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName). _
            Split(New String() {vbCrLf, vbCr, vbLf}, StringSplitOptions.RemoveEmptyEntries)

ljw1004 fucked around with this message at 22:34 on Sep 12, 2011

ray2k
Feb 7, 2004

Puppet scum beware!
Anyone using Resharper 5 with Visual Studio 2010? I thought I'd give it a try again, and it immediately gets in my way on the very first line of code I write. I type List< and then the closing > is inserted after the cursor. Ok great, bracket completion- except that when I type > myself both of them stay (syntax error), and if i dont I have to skip over it using right-arrow or end key. How is that any more helpful than me just writing my own drat brackets? Am I missing something?

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat
I'm developing an app in c#, however this one is a bit more involved than what I've done in the past with the .net framework. It's a form based application, and by default it looks like every bit of information I've seen has the creation and navigation of multiple forms handled by the forms themselves. Is this really the standard practice, or is it just because the default code generated by the project wizards tends to lean in this direction?

Dietrich
Sep 11, 2001

CRIP EATIN BREAD posted:

I'm developing an app in c#, however this one is a bit more involved than what I've done in the past with the .net framework. It's a form based application, and by default it looks like every bit of information I've seen has the creation and navigation of multiple forms handled by the forms themselves. Is this really the standard practice, or is it just because the default code generated by the project wizards tends to lean in this direction?

Sweet merciful crap do not do your application that way.

Begby
Apr 7, 2005

Light saber? Check. Black boots? Check. Codpiece? Check. He's more machine than kid now.

ray2k posted:

Anyone using Resharper 5 with Visual Studio 2010? I thought I'd give it a try again, and it immediately gets in my way on the very first line of code I write. I type List< and then the closing > is inserted after the cursor. Ok great, bracket completion- except that when I type > myself both of them stay (syntax error), and if i dont I have to skip over it using right-arrow or end key. How is that any more helpful than me just writing my own drat brackets? Am I missing something?

I ended up turning all that crap off. It seems like they need to do some polish. Also it would be nice if it was easier to turn some of that stuff on and off easier and if they didn't just automatically change everything the second after you installed it.

For instance after I installed it it started indenting all my curly brackets really far even after I turned off a bunch of features. I had to go in and uncheck 3 boxes that were spread throughout the options screens after googling the problem.

And here all I wanted was a good testrunner for NUnit.

Begby
Apr 7, 2005

Light saber? Check. Black boots? Check. Codpiece? Check. He's more machine than kid now.

thehandtruck posted:

Notice how I had to comment out some 'Call' lines because they wouldn't compile. I've tried every combination and even looked at my previous programs but it doesn't to work. I can declare it, but then it screws up the Cust array. What a mess.

Those call lines you commented out appear to refer to methods that don't exist in the sample you provided. If they do exist, then what kind of compile errors are you encountering?

ray2k
Feb 7, 2004

Puppet scum beware!

Begby posted:

And here all I wanted was a good testrunner for NUnit.

Pretty much what I was looking for, the only other thing being 'move type to file'. I'm really not getting all the resharper love the .net bloggers and MVPs seem to have.

jarito
Aug 26, 2003

Biscuit Hider

Dietrich posted:

Sweet merciful crap do not do your application that way.

Is there an accepted way to do this? I typically do web development, but I would be interested in what would be considered best practice here.

Fiend
Dec 2, 2001
edit: nevermind.

Fiend fucked around with this message at 18:00 on Apr 28, 2010

blorpy
Jan 5, 2005

I know the OP has a few books linked, but what which one(s) would you guys suggest for someone wanting to learn C# and is completely new to .NET but has a lot of C and Python experience? What about learning WPF?

thehandtruck
Mar 5, 2006

the thing about the jews is,

Begby posted:

Those call lines you commented out appear to refer to methods that don't exist in the sample you provided. If they do exist, then what kind of compile errors are you encountering?

Error 1 Value of type '1-dimensional array of Hotel.Form1.Customer' cannot be converted to '1-dimensional array of String' because 'Hotel.Form1.Customer' is not derived from 'String'.

If I do

code:
Dim custname(60) As String
then the error goes away, but I'm not sure it actually works because I've messed around with the code so much at this point I can't tell where the program is hitting walls.

and if I add "Dim CustNames(60) as String" (to remove the error for the Call printArrays)

I get the Format Exception:
Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
on line "lstDisplay.Items.Add(String.Format(fmtZone, CustNames(i)))"

which is the main problem I'm having right now.

thehandtruck fucked around with this message at 00:01 on Apr 28, 2010

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat

Dietrich posted:

Sweet merciful crap do not do your application that way.

I would never do that, but I'm trying to find a single example of how it should be done. I've created proper GUI application frameworks in C, C++, Flex, etc. but it seems the way that .net uses forms that it doesn't seem to be very easy to implement a decent application framework.

Zhentar
Sep 28, 2003

Brilliant Master Genius

thehandtruck posted:

Error 1 Value of type '1-dimensional array of Hotel.Form1.Customer' cannot be converted to '1-dimensional array of String' because 'Hotel.Form1.Customer' is not derived from 'String'.

Well, you didn't give us the definitions we need, but the error suggests it. I'm assuming printArrays looks something like this:
code:
Sub PrintArrays(Values() As String)
Now, the error message there is pretty clear; read through it carefully. You have an array of type Customer. You need an array of type String. The compiler does not know how to make a array of String from an array of Customer.

That means you either have to change PrintArrays so that it accepts an array of Customer, or you have to make build an array of String yourself to send to PrintArrays.

dwazegek
Feb 11, 2005

WE CAN USE THIS :byodood:
Is there a bug in .NET 4.0's System.Diagnostics.Debugger.Launch()?

If I don't attach a debugger, the process just quits, no exceptions, error messages or anything.

In .NET 3.5 and below, the function just returns false and the process keeps on doing its merry little thing.

There aren't any changes to the MSDN documentation and I don't see any changes in Reflector either.

Dietrich
Sep 11, 2001

jarito posted:

Is there an accepted way to do this? I typically do web development, but I would be interested in what would be considered best practice here.

Create a singleton shell class that you can issue commands to- ie: Shell.OpenOrdersForm

That way when you get all fancy with needing to make sure a form can only be opened once or with switching forms to an active window in order to prompt it's easy to do, and you can obfuscate the various form construction methods from other forms so that you only have to change things in one place.

Iron Squid
Nov 23, 2005

by Ozmaugh
Can anyone recommend a decent book on learning C#?

Adbot
ADBOT LOVES YOU

Horse Cock Johnson
Feb 11, 2005

Speed has everything to do with it. You see, the speed of the bottom informs the top how much pressure he's supposed to apply. Speed's the name of the game.

Iron Squid posted:

Can anyone recommend a decent book on learning C#?

Look for the latest version of Jessee Liberty's Programming C#.

  • Locked thread