datagrid help

D0M1N8R

Member
Joined
Mar 14, 2007
Messages
11
Programming Experience
Beginner
Taking a VB.net class and a simple first project has been assigned to us.
The objective is to take a text file filled with comma separated values and display them fields as well as being able to sort them
I was looking through toolbox and seen the datagrid which looks like it may be a great solution for this project but am so far unable to figure out how to assign data programatically to each individual cell.
I have not been able to find any information on this so far and need some help. So here I am =)
Thanks
 
The course I'm taking is on programing fundamentals. The goal is basically just to get to know the fundamentals of how to put together a program. Its a 3 month course thats almost over and required for my information technology and security degree.
Instructor him self has just touched on VB and seems to like the idea that I'm pursuing getting something done beyond the scope of the course.
As a Linux user I like the idea of being open on ideas. I love being able to count on a community for help and helping other where I can.
The instructor says programing is like art. Everyone will have a different way of painting the same picture. I see some of that between you both.
He also says that you should always communicate your ideas because you will never nail the absolute best way of getting everything done. Through communication and gathering of other ideas you will shape your work into something better then you had envisioned.

I was hoping to get more done today but gotta take off to work so outa time. Guess better luck tomorrow.
 
Well its all working now but there is some major issues!
When everything was said and done there is literally like 2 lines of code. LoL
So I know one goal was creating a sort routine. I wasnt too concerned about this since its only worth 5 points. How ever I think it would help me get a couple other goals done (creating a custom sub and a function each worth 10 points).
This thing is due tomorrow morning.
My main issue here is of course you cant find any info on how to actually do a programmatic sort on a datagrid since no one has probably cared enough to do it.. never even mind write a tutorial. I see the setting to set it to programatic but other then that.. No info.
 
(Even if you arent doing a custom routine, but a normal boring straight routine, you can guess how to straight sort it from this customised tutorial. I think the first link was an article that MS wrote)
 
I was unable to figure out a few things in doing this (basically how to manipulate whats in the cells) so went into class and showed the instructor what I had. He gave me a couple more days to come up with a sub and function. Doesn't care if all they do is change color properties. I'll see what I can do.
 
You have to change the colour of the cell depending on its value?

You can make a Sub/Function quite easily, without going so technical..

Heck, even a button click handler event is a Sub.. You msut have one of those! Have you got a more precise spec of what is demanded of you?
 
At the moment with whats done at this point just need to create a function and a sub. basically just demonstrate I know how to create one. He really doesn't care how dumb it is so long as it has been created.
I'm thinking of just adding a few buttons to change color themes or something like this.
Going to be working on it tonight.
 
show me the code you have so far; you might be able to extract some of it (sensibly) to a sub/function
 
Before today there was basically no code. Just one line for a close button and one line to datagrid.

I just put together some code just for the main form title.


VB.NET:
Public Class FrmCustList

    Private Sub FrmCustList_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        SetTitle("The Tonya Project")
        'This line of code loads data into the 'ODBCCustList1.DTCustList' table. 
        Me.DTACustList.Fill(Me.ODBCCustList1.DTCustList)
    End Sub

    Private Sub DTCustListDGV_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DTCustListDGV.CellContentClick

    End Sub

    Private Sub DTCustListBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub BindingNavigatorDeleteItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub


    Private Sub DTCustListBindingNavigator_Refre****ems(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DTCustListBindingNavigator.Refre****ems

    End Sub

    Private Sub DTCustListBindingSource_CurrentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DTCustListBindingSource.CurrentChanged

    End Sub
    'Close button to exit out of application
    Private Sub BtnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnClose.Click
        Close()
    End Sub

    Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub
    'Purpose of this sub is to programatically for fun set the title for the main window
    'A is the original title passed over from FrmCustList (Main Window Code)
    Private Sub SetTitle(ByVal A As String)
        Dim Title As String
        Title = NameGenerator(A)
        MyBase.Text = Title
    End Sub
    'A is the original title passed over from SetTitle Sub for analysing and customizing
    Private Function NameGenerator(ByVal A As String)
        Dim Tonya As String = A
        Dim Title As String = ""
        Dim Count As Integer
        For Count = 0 To (Tonya.Length - 1)
            If Tonya(Count) = " " Then
                Title = Title & "*-* "
            Else
                Title = Title & "(" & Tonya(Count) & ") "
            End If
        Next
        Return Title
    End Function

End Class

Seems to work fine!
 
all the empty subs need removing


name your variables something better than A, especially in parameters. which of the following intellisense tooltip helps would you rather see:

AddNewShopItem(itemName as String, itemWeight as Double, itemPrice as Double, onSepcialOffer as Boolean)
AddNewShopItem(P1 as String, P2 as Double, P3 as Double, P4 as Boolean)

I usually find that starting variable names with a lowercase letter helps distinguish them from classes. Which of these is an instance variable and which is a static method call:

something.MyFunction()
Something.MyFunction()


[/B]
 
you're right, and it believe it's part of the naming conventions as well. I did turn my project today and scored pretty well. Thanks cjard for all your help.
 
Back
Top