?
Solved

Need help learning Datagrid Basics

Posted on 2007-07-27
6
Medium Priority
?
210 Views
Last Modified: 2013-11-07
I am very new to datagrids, so new that I am having a hard time grasping the concept. I would like to teach it to myself with the aid of you, the expert. Currently I am only interested in unbound datagrids.

I have been looking all over the web and can not find any learning material that will help me reach my goal.

I find the best way to learn is by example so will begin by posting a series of questions...starting out simple and progressing forward. I know what I want for an end product but do not want to post a question that is miles long when I do not understand the basics. The bottom line is I want to learn and not just get code so here goes...

DATAGRID QUESTION 1

I am using VB.Net 2005 SP1 Compact Framework

I have added a datagrid called dgTest to Form1. This has to be unbound. I want to add 4 columns 3 will be textboxes and one will be a combobox.

Col 1 textbox Header Name: Client ID
Col 2 textBox Header Name: First
Col 3 textBox Header Name: Last
Col 4 combobox Header Name: Color

All Columns and Header names are to be visible

The textboxes will be blank but the combobox will have the values of "Red", "Blue", "Orange" and can not accept typed in data. It has to be a selected value.

The total width of the datagrid is 226. I need the width of each column to be 56.

How do I do this?

Thanks

PBLack
0
Comment
Question by:PBLack
  • 4
  • 2
6 Comments
 
LVL 48

Accepted Solution

by:
jpaulino earned 2000 total points
ID: 19582976
0
 

Author Comment

by:PBLack
ID: 19583020
None of those links answer my question. You see I do not want to add info from a datasource. I want to be able to add user entered data to each row in the datagrid and then add that data to a table later on. Right now I just want to know how to create the datagrid - an empty shell so-to-speak.

PBLack
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 19583040
But in this example you can see how insert column and rows by code, without datasource.
>> http://samples.gotdotnet.com/quickstart/CompactFramework/doc/datagridadding.aspx
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
LVL 48

Expert Comment

by:jpaulino
ID: 19583056
If you understand (more or less) C# you can look for this good guide http://www.codeproject.com/csharp/PracticalGuideDataGrids1.asp
0
 

Author Comment

by:PBLack
ID: 19583076
I tired the following code and was met with errors:

1) maxColumnNumber is not declared
2) dataTable is not declared

Dim newColumnName As String
Dim index As Integer

' Increment the max column number.
maxColumnNumber += 1

' Construct name for new column.
newColumnName = "C " + maxColumnNumber.ToString()

' Create a new column.
dataTable.Columns.Add(newColumnName, Type.GetType("System.String"))

' Add data to each row in the table for the new column.
For index = 0 To dataTable.Rows.Count - 1
      dataTable.Rows(index)(newColumnName) = "R " + index.ToString() + ", " + newColumnName
Next index      
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 19583085
Sorry I'm not in my computer but ...

You have to declare the variables, so:

Dim maxColumnNumber As Integer
Dim dataTable as New DataTable
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month16 days, 21 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question