c# Adjust column of datagridview

Hi,

I have 5 columns, in one coumn sometimes the message short, and long. Those are long , really long. it makes the coumns looked not nice, and affect to the next column which sometimes are
pushed to the right border.
I'd like ,say ,check one of the message in any row, and if its lenght is > 40 characters, this message will be choped, and added to the end "..." indicating users can click on this row to see the full message in the drop down list. Could you please give me a smaple for this tehcnique?

Thanks,
JT
jtran007Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AndyAinscowFreelance programmer / ConsultantCommented:
If you specify a width for the column when creating/designing the gridview then the columns should keep that width - in other words this should not be necessary.
Have a look at how you are setting up the gridview.
0
jtran007Author Commented:
Hi,

I have...

 DataGridViewColumn par = datagrid.Columns["Products"];
 par.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;

Now I'd like to be able to click on this row, and the contend of this cell will be expanded. How can I do it?

Thanks,
JT
0
AndyAinscowFreelance programmer / ConsultantCommented:
That is rather a different question, one I don't know the answer to offhand.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

sumeetsuviCommented:
content will expand their or releated data will open on other page...?
0
sumeetsuviCommented:
Is this a web page or window............
If web then u can use RowDataBound Event of grid.... it is easy to play with data in this event..
0
AndyAinscowFreelance programmer / ConsultantCommented:
As far as I understand the question my comment  #35273401 will solve the original request.
Are you saying you had fixed the width at design time but it didn't maintain it?
0
jtran007Author Commented:
Hi,

For datagridview, I found the CoolTipText... attribute of the datagridview, that I can use to dynamically
change the width of the grid.

Thanks for your answer. Can I close this issue?

Regards,
JT
0
AndyAinscowFreelance programmer / ConsultantCommented:
Do you mean ToolTipText ?
Note that has nothing to do with the original question - it is not involved with sizing a column.


>>Can I close this issue?
Yes
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jtran007Author Commented:
Hi,

Yes you are right.: sorry.Since in my question I said if the content of a row is too long, user can click on it and display in full content. The only solution is using toottipText that my supervisor recommends.

Thanks anyway.

So can I close this issue?

Regards,
JT
0
AndyAinscowFreelance programmer / ConsultantCommented:
In your question you also said:
Those are long , really long. it makes the coumns looked not nice, and affect to the next column which sometimes are
pushed to the right border.

which looked like the real problem you had was the width being set automatically.  My first comment adressed that.

I think you need a combination - my suggestion to set the widths at design time (so it maintains a good display) and your ToolTipText to display the full text when the mouse is over a cell.
If you are in agreement then I would suggest you use the option to select multiple answers (my first comment and your ToolTipText comment) and split the points between them.
0
jtran007Author Commented:
Thanks.,
JT
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.