I have a DataGridView which has a cell that is going to contain what might
be a large amount of text data. The UI designed has decreed that each row
will have a button that toggles the row's multiline display such that, when
the button is up, the row is a single line and when the button is down, the
row enters a multiline mode so that the cell can expand to a height great
enough to display all of the cell's contents. I've figured out how to make a
column of buttons but the toggling between multi and single line is giving
me trouble. How can this be done?
--
Richard Lewis Haggard www.Haggard-And-Associates.com 3 24983
Here is one way you can attempt to do this. Handle the CellPainting
event. In your event handler, somehow test whether the cell being
painted is one of your potential multiline cells (not sure how you
would do this in your particular case, but you would have the row and
column index among other properties that you could use in your test).
If the cell should be multiline, then set the WrapMode property. Then,
finally, in your button click code, you would some how make the grid
refresh itself (maybe calling dataGridView.Refresh) so the cell would
be redrawn with the correct WrapMode setting. This way every time teh
cell is drawn, the proper WrapMode is dynamically determine.
void dataGridView1_CellPainting(object sender,
DataGridViewCellPaintingEventArgs e)
{
if (e.ColumnIndex == 2 && e.RowIndex -1 &&
dataGridView1[0, e.RowIndex].Value.Equals("1"))
{
e.CellStyle.WrapMode = DataGridViewTriState.True;
}
}
===================
Clay Burch
Syncfusion, Inc.
On Mar 20, 1:50 pm, "ClayB" <c...@syncfusion.comwrote:
Here is one way you can attempt to do this. Handle the CellPainting
event. In your event handler, somehow test whether the cell being
painted is one of your potential multiline cells (not sure how you
would do this in your particular case, but you would have the row and
column index among other properties that you could use in your test).
If the cell should be multiline, then set the WrapMode property. Then,
finally, in your button click code, you would some how make the grid
refresh itself (maybe calling dataGridView.Refresh) so the cell would
be redrawn with the correct WrapMode setting. This way every time teh
cell is drawn, the proper WrapMode is dynamically determine.
void dataGridView1_CellPainting(object sender,
DataGridViewCellPaintingEventArgs e)
{
if (e.ColumnIndex == 2 && e.RowIndex -1 &&
dataGridView1[0, e.RowIndex].Value.Equals("1"))
{
e.CellStyle.WrapMode = DataGridViewTriState.True;
}
}
===================
Clay Burch
Syncfusion, Inc.
I usually display multi-line text in a textbox within the cell, and
show/hide the textbox accordingly.
Another approach maybe using tooltip to display the full text if mouse
hover-over. There are
some custom tooltip out there.
Quoc Linh
This worked great. Thanks!
--
Richard Lewis Haggard www.Haggard-And-Associates.com
"ClayB" <cl***@syncfusion.comwrote in message
news:11*********************@o5g2000hsb.googlegrou ps.com...
Here is one way you can attempt to do this. Handle the CellPainting
event. In your event handler, somehow test whether the cell being
painted is one of your potential multiline cells (not sure how you
would do this in your particular case, but you would have the row and
column index among other properties that you could use in your test).
If the cell should be multiline, then set the WrapMode property. Then,
finally, in your button click code, you would some how make the grid
refresh itself (maybe calling dataGridView.Refresh) so the cell would
be redrawn with the correct WrapMode setting. This way every time teh
cell is drawn, the proper WrapMode is dynamically determine.
void dataGridView1_CellPainting(object sender,
DataGridViewCellPaintingEventArgs e)
{
if (e.ColumnIndex == 2 && e.RowIndex -1 &&
dataGridView1[0, e.RowIndex].Value.Equals("1"))
{
e.CellStyle.WrapMode = DataGridViewTriState.True;
}
}
===================
Clay Burch
Syncfusion, Inc. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Art |
last post by:
Hi,
I'm having some trouble with my DataGridView. I have it bound to a
DataTable. One column of the grid is a boolean that says whether a row
should be visible. There is also a checkbox...
|
by: lv2compute |
last post by:
I am having a problem with my datagridview. I have a small table that
has two columns. The first column is bound to my dataset. The second
column is a combobox. I add items to the combobox based on...
|
by: jon.paine |
last post by:
Hi All -
I'm working on my first real c# windows forms - but I've done c# web
development for awhile. The problem that I'm running into is with
defining a layout structure for a dataGridView...
|
by: BillE |
last post by:
What is the best way to add data using a DataGridView in a multi-tier
application (data entry is handled in a data access layer using stored
procedures)?
Thanks
Bill
|
by: =?Utf-8?B?UmljaA==?= |
last post by:
I have code to bold text in a datagridviewcell:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim cs As DataGridViewCellStyle, fnt...
|
by: Bill Nguyen |
last post by:
I can't figure out how to identify/display the column header name in
Mouseclick event.
This is a checkbox column type and I would like all cells in this column to
toggle checked/unchecked when the...
|
by: Alcibiade |
last post by:
Hi, I have 2 questions:
1)if width datagridview is shorter than form witdh, user will see
horizontal scrollbar to see all grid.How can I adapt width form to
width datagridview?
2) If a cell...
|
by: Steve K |
last post by:
to this newline when an enter key is detected.
Update: I tried adding this code:
<code>
public PMDDataGridViewTextBoxEditingControl()
:base()
{
this.Multiline = true;
}
</code>
|
by: evilson |
last post by:
Hi,
I have two textbox, one of the textbx is is set to multiline. Problem is when i try to insert the value of the multiline textbox to the datagridview, it never work. The datagrid's warpmode is...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |