prevent newline in datagrid

  • Thread starter Thread starter André Giesing
  • Start date Start date
A

André Giesing

Hello Newsgroup!

I have a DataGrid. In the cells of this DataGrid are strings displayed which
consists of more then one word. When the collum of the DataGrid is not wide
enough, ervery word of the hole string is displayed in a own line in the
cell.
How can i prevent the newline?
Any ideas?

Thanks!
 
It seems, you have a tab char instead of space char separating the words.
Check it.
ThanQ...
 
Sorry for late reply. I was not at my machine. Try coding to similar to the
following sub. This code is from a project 'GridDemo' by Alex. Unfortunately
I don't have the link for it (If Alex is watching this thread, he may
provide the link). Of course this is in C#, but it can be converted to VB
very easily. The attached screen shot shows how it looks on the PPC. Here
long text containing space chars between words is displayed in a grid column
which is not wide enough. If it works, thank Alex Fienman.
-------------------------------------------------
// Create and populate data set. The data set will have one table called
"Books", that

// contains book title, price and whether it is in stock. For the sake of
simplicity the InStock

// column is string. To do it properly, it must have been made a bool and
then we would create a calculated

// (expression-based) column to display its contents as Yes/No. The grid
column would be then bound to

// this calculated column

void PopulateDataSet()

{

// Create data set

ds = new DataSet("Dataset");

// Add a table

tbl = ds.Tables.Add("Books");


// Define table columns

DataColumn clmnID = tbl.Columns.Add("ID", typeof(int));

tbl.Columns.Add("Title", typeof(string));

tbl.Columns.Add("Price", typeof(float));

tbl.Columns.Add("InStock", typeof(string)).DefaultValue = "No";


// Define primary key

tbl.PrimaryKey = new DataColumn[] { clmnID };

// Make ID column autoincrement

clmnID.AutoIncrement = true;

clmnID.AllowDBNull = false;


// Fill in table data

tbl.Rows.Add(new object[] { 1, "The Busy Executive's Database Guide",
12.95f, "Yes" });

tbl.Rows.Add(new object[] { 2, "Cooking with Computers: Surreptitious
Balance Sheets", 17.95f });

tbl.Rows.Add(new object[] { 3, "You Can Combat Computer Stress!", 11.95f,
"Yes" });

tbl.Rows.Add(new object[] { 4, "Straight Talk About Computers", 12.35f });

tbl.Rows.Add(new object[] { 5, "Silicon Valley Gastronomic Treats",
15.45f });

tbl.Rows.Add(new object[] { 6, "The Gourmet Microwave", 12.25f, "Yes" });

tbl.Rows.Add(new object[] { 7, "The Psychology of Computer Cooking", 6.95f,
"Yes" });

tbl.Rows.Add(new object[] { 8, "But Is It User Friendly?", 21.95f });

tbl.Rows.Add(new object[] { 9, "Secrets of Silicon Valley", 14.95f });

tbl.Rows.Add(new object[] { 10, "Net Etiquette", 11.95f });

tbl.Rows.Add(new object[] { 11, "Computer Phobic AND Non-Phobic Individuals:
Behavior Variations", 16.95f });

tbl.Rows.Add(new object[] { 12, "Is Anger the Enemy?", 12.75f, "Yes" });

tbl.Rows.Add(new object[] { 13, "Life Without Fear", 10.95f });

tbl.Rows.Add(new object[] { 14, "Prolonged Data Deprivation: Four Case
Studies", 12.95f });

tbl.Rows.Add(new object[] { 15, "Emotional Security: A New Algorithm",
9.95f });

tbl.Rows.Add(new object[] { 16, "Onions, Leeks, and Garlic: Cooking Secrets
of the Mediterranean", 1.99f, "Yes" });

tbl.Rows.Add(new object[] { 17, "Fifty Years in Buckingham Palace Kitchens",
50.95f });

tbl.Rows.Add(new object[] { 18, "Sushi, Anyone?", 1.95f });

}

-------------------------------------------------
 
But, Andre's problem was, words are spread across rows, that's not expected.
Alex Feinman said:
http://www.alexfeinman.com/download.asp?doc=GridDemo.zip

But I'm afraid it won't help much. The grid will wrap text if rowheight is
sufficient for more than one row. If the rowheight is left default, the text
will be cut off.

Shanti said:
Sorry for late reply. I was not at my machine. Try coding to similar to the
following sub. This code is from a project 'GridDemo' by Alex. Unfortunately
I don't have the link for it (If Alex is watching this thread, he may
provide the link). Of course this is in C#, but it can be converted to VB
very easily. The attached screen shot shows how it looks on the PPC. Here
long text containing space chars between words is displayed in a grid column
which is not wide enough. If it works, thank Alex Fienman.
-------------------------------------------------
// Create and populate data set. The data set will have one table called
"Books", that

// contains book title, price and whether it is in stock. For the sake of
simplicity the InStock

// column is string. To do it properly, it must have been made a bool and
then we would create a calculated

// (expression-based) column to display its contents as Yes/No. The grid
column would be then bound to

// this calculated column

void PopulateDataSet()

{

// Create data set

ds = new DataSet("Dataset");

// Add a table

tbl = ds.Tables.Add("Books");


// Define table columns

DataColumn clmnID = tbl.Columns.Add("ID", typeof(int));

tbl.Columns.Add("Title", typeof(string));

tbl.Columns.Add("Price", typeof(float));

tbl.Columns.Add("InStock", typeof(string)).DefaultValue = "No";


// Define primary key

tbl.PrimaryKey = new DataColumn[] { clmnID };

// Make ID column autoincrement

clmnID.AutoIncrement = true;

clmnID.AllowDBNull = false;


// Fill in table data

tbl.Rows.Add(new object[] { 1, "The Busy Executive's Database Guide",
12.95f, "Yes" });

tbl.Rows.Add(new object[] { 2, "Cooking with Computers: Surreptitious
Balance Sheets", 17.95f });

tbl.Rows.Add(new object[] { 3, "You Can Combat Computer Stress!", 11.95f,
"Yes" });

tbl.Rows.Add(new object[] { 4, "Straight Talk About Computers", 12.35f });

tbl.Rows.Add(new object[] { 5, "Silicon Valley Gastronomic Treats",
15.45f });

tbl.Rows.Add(new object[] { 6, "The Gourmet Microwave", 12.25f, "Yes" });

tbl.Rows.Add(new object[] { 7, "The Psychology of Computer Cooking", 6.95f,
"Yes" });

tbl.Rows.Add(new object[] { 8, "But Is It User Friendly?", 21.95f });

tbl.Rows.Add(new object[] { 9, "Secrets of Silicon Valley", 14.95f });

tbl.Rows.Add(new object[] { 10, "Net Etiquette", 11.95f });

tbl.Rows.Add(new object[] { 11, "Computer Phobic AND Non-Phobic Individuals:
Behavior Variations", 16.95f });

tbl.Rows.Add(new object[] { 12, "Is Anger the Enemy?", 12.75f, "Yes" });

tbl.Rows.Add(new object[] { 13, "Life Without Fear", 10.95f });

tbl.Rows.Add(new object[] { 14, "Prolonged Data Deprivation: Four Case
Studies", 12.95f });

tbl.Rows.Add(new object[] { 15, "Emotional Security: A New Algorithm",
9.95f });

tbl.Rows.Add(new object[] { 16, "Onions, Leeks, and Garlic: Cooking Secrets
of the Mediterranean", 1.99f, "Yes" });

tbl.Rows.Add(new object[] { 17, "Fifty Years in Buckingham Palace Kitchens",
50.95f });

tbl.Rows.Add(new object[] { 18, "Sushi, Anyone?", 1.95f });

}

-------------------------------------------------

André Giesing said:
No, a space char seperates the words.

It seems, you have a tab char instead of space char separating the words.
Check it.
ThanQ...
Hello Newsgroup!

I have a DataGrid. In the cells of this DataGrid are strings displayed
which
consists of more then one word. When the collum of the DataGrid is not
wide
enough, ervery word of the hole string is displayed in a own line
in
the
cell.
How can i prevent the newline?
Any ideas?

Thanks!
 
Back
Top