We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

text llignment in cell

Good morning, How do set the text allignment propert of the cells in a column to right,centre. but i would also like some cells to beright alligned because i use them for keydon event controlled numeric data entry. No, i dont want to use a text edit control. also, if i used covered cells then for text i will have merged cell like effect?. I want to enter a question in a collection of rows, same column. This was possible in c1 grid only by loading all the rows with the text and then requesting it to merge . If covercell has same effect i may not require any merging at all. How do i make the entire grid readonly like my flavourless old vanilla grid.

10 Replies

AD Administrator Syncfusion Team September 24, 2004 03:14 PM UTC

Hi Mahesh, you can set the ColStyles.Item(col).HorizontalAlignment = GridHorizontalAlignment.Center or ColStyles.Item(col).HorizontalAlignment = GridHorizontalAlignment.Right to cover cells you call CoveredRanges.Add(range) this will make all cells of the given range become one large cell and the alignemnt and all other cell settings are applied to this one cell. See the CoveredCells sample app under Grid\Samples. If you want to automatically join cells based on contents then you need to set the merge cells feature as discussed in the other thread. The difference between covered cells and merge cells basically is that you specify covered cells manually and they can span horizontally and vertically. Merge cells will be determined automatic by the grid based on cell content. They can only span either rows or columns but not both at the same time. If you do not want allow editing individual cells within a merged cell try set GridStyleInfo.CellType = "Static" for that column or row. Stefan


MN Mahesh Naik September 25, 2004 12:15 PM UTC

thank you. In a covered range i will have my question text automatically wrapping within the cell, right?. or does it truncate the text to fit the width of a single line. My very special mumdane need requires questions in 1 column.The question text spans multiple rows....


MN Mahesh Naik September 25, 2004 12:32 PM UTC

I want the full grid to be readonly as i am handling the precious keystrokes via the keydown event. so how ? there are 17 instances of the gridcontrol. each with a different # of rows. > >thank you. >In a covered range i will have my question text automatically wrapping within the cell, right?. or does it truncate the text to fit the width of a single line. My very special mumdane need >requires questions in 1 column.The question text spans multiple rows.... >


AD Administrator Syncfusion Team September 25, 2004 07:31 PM UTC

Text is Static or TextBox celltypes should wrap lines if you set style.WrapText = true; for those cells. You can make the whole grid readonly by setting: gridControl1.ReadOnly = true;


MN Mahesh Naik September 26, 2004 09:13 AM UTC

the readonlu had a different effect (as it should be) than what i wanted.I donot want the gridcontrol to handle the editing. i trap the keydown events and move the cursor up or down , or get numbers for a numeric field. making it readonly disallows even beautiful colours as it amounts to a non read operation. also the left column seems to be a fixed grid ? and so does the top row. They refuse to accept the allignment changes which work in the 2nd column. How do i control their behaviour(oth column, oth row).Also i have a additional column with a title D(i didnot wish for that). How do i tell the program that i donot need that additional column at the right end. sunday, 17:43 IST


AD Administrator Syncfusion Team September 26, 2004 09:56 AM UTC

Are you using a GridControl? If so, you set the grid.ColCount to be the number of columns you want to see in the grid excluding the row header column. So, if you want to see 4 columns plus a row header column, you set grid.ColCount = 4. The zeroth column is the row header column. You controls its style properties like color and alignment through the Row Header basestyle. //color row headers this.gridControl1.BaseStylesMap["Row Header"].StyleInfo.BackColor = Color.Red; //color top left corner this.gridControl1.BaseStylesMap["Header"].StyleInfo.BackColor = Color.Red; //column column headers this.gridControl1.BaseStylesMap["Column Header"].StyleInfo.BackColor = Color.Red;


MN Mahesh Naik September 26, 2004 11:52 AM UTC

thank you, i have now understood the convention. Either way i will have to dirty my working code. Waht i understand is that the header rows and header columns are not included in the rocount and colcount...right?. but while indexing row 0 is the tomost row, col 0 correspondsto the hr=eaderows. Is there a way just to make them disappear form the display if i dont want them....i mean width =0 or height =0. I want a mergeeffect in the header rows. I mean column 0.I am using that column to display question no for a question which spans > 1 row. now only 1 major hurdle, how do i stop your editing. I have my ouwn vanilla which i wrote for msflexgrid .ocx. and i love that though i agree that child is not cute but it is my child.My application is unusual. I have a data entry program for a survey questionaire. Quite lengthy ..works fine with the .old .vbx and also with Component one. Your grid has one unique feature which i was hunting for .I will try that only after i make my old stuff work as is.


AD Administrator Syncfusion Team September 26, 2004 11:14 PM UTC

You can hide the headers using: this.gridControl1.Properties.ColHeaders = false; this.gridControl1.Properties.RowHeaders = false; Or, you can set grid.Cols.Hidden[0] = true. You can use grid.CoveredRanges.Add to have covered cells in column 0 (the row headers) you you want covered cells in the row headers. Or, you can hide the headers, and cover cells in column 1 if you want that.


MN Mahesh Naik September 27, 2004 05:55 AM UTC

yes , for a change os taste i will try covering up. thank you


MN Mahesh Naik September 27, 2004 08:54 AM UTC

I uses cover and got the desired effect but now the giant cell is covered by a different lined voundry.Dont the table grid settings apply to the covered up cells?. logicaaly if i have to refer a covered up cell by its leftmostcorner then what about the row,col indices which have become part of the covered cell? If i know the cells to merge beforehand is the coverup operation better?

Loader.
Live Chat Icon For mobile
Up arrow icon