By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,238 Members | 1,771 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,238 IT Pros & Developers. It's quick & easy.

Need basic help with DataGrid/Listbox controls

P: n/a
I am trying to display some information from a database in a form that
displays one record per line. When the user clicks anywhere on a line, that
record is highlighted and selected, and my program will respond to that. The
problem is that with a listbox control (which is what it sounds like I need),
I can't get the information to format at all. \t-Tabs skew the data
unpredicatably - it leaves some words closer together on some lines than
others. Spaces are not appropriate either because I am trying to get the data
to display in psuedo-columns - ie: last name, firstname, SS, etc. The
DataGrid looks great as far as formatting goes, but when a user clicks on a
DataGrid cell, It just selects that cell, and it highlights the text like it
wants to be edited - even if its a read-only Datagrid. Is there a way to make
rows of a DataGrid select all the way across like data in a ListBox? Or Is
there a way to reliably format the data in a listbox? Right now for the
listbox I am using this:

String listHolder;
foreach(DataRow row in dtaRows)
{
listHolder = row["lastname"].ToString()+ ", \t"+
row["firstname"].ToString()+"\t"+row["middlename"].ToString()+"\t"+row["ss"].ToString();
this.listBox1.Items.Add(listHolder);
}

What are my options??? I can't figure out how to make it do what I'm looking
for with either control. I only need one of them to work. I would definately
prefer the DataGrid though. Any ideas/suggestions? Thanks.

Eric
Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi,

If you mean no current cell (whole row is selected), I'm just adding it to
my grid.

You may try out (free open source master/detail gird):
(grid.gif picture of grid; lumisoft.grid.zip sample app + grid)
http://www.lumisoft.ee/lsWWW/download/downloads/UI/NET/

"ericm1155" <er*******@discussions.microsoft.com> wrote in message
news:61**********************************@microsof t.com...
I am trying to display some information from a database in a form that
displays one record per line. When the user clicks anywhere on a line,
that
record is highlighted and selected, and my program will respond to that.
The
problem is that with a listbox control (which is what it sounds like I
need),
I can't get the information to format at all. \t-Tabs skew the data
unpredicatably - it leaves some words closer together on some lines than
others. Spaces are not appropriate either because I am trying to get the
data
to display in psuedo-columns - ie: last name, firstname, SS, etc. The
DataGrid looks great as far as formatting goes, but when a user clicks on
a
DataGrid cell, It just selects that cell, and it highlights the text like
it
wants to be edited - even if its a read-only Datagrid. Is there a way to
make
rows of a DataGrid select all the way across like data in a ListBox? Or Is
there a way to reliably format the data in a listbox? Right now for the
listbox I am using this:

String listHolder;
foreach(DataRow row in dtaRows)
{
listHolder = row["lastname"].ToString()+ ", \t"+
row["firstname"].ToString()+"\t"+row["middlename"].ToString()+"\t"+row["ss"].ToString();
this.listBox1.Items.Add(listHolder);
}

What are my options??? I can't figure out how to make it do what I'm
looking
for with either control. I only need one of them to work. I would
definately
prefer the DataGrid though. Any ideas/suggestions? Thanks.

Eric

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.