Possibly you create new instance of ColumnStyles or TextBoxColumns each time
you handle the event. If that is true, then try change value of existing
object insted of creating new one.
Any way you can try to remember cell value before changing width and restore
it after width is changed....
In general to achve functionality like in MS-Word you will have to write all
code by ourself. You may calc avarege width of coloumns in our datagrid and
if curent cell width is bigger then avarege*2 then increse higth insted of
future incresing width.
Or do it other way.
-----------------
Good luck!
Andry
"Pramod" wrote:
> Hi Andry,
> I have used ColumnStyles and TextBoxColumns and handled the KeyPress event
> but now the problem is if I increase the width of the column the earlier
> Text gets cleared as the width goes on increasing. i.e. If i have entered
> "Andry" and the text now exceeds the width of the Column size the column
> size increases but "Andry" gets deleted and whichever alphabet i type next
> is seen.
>
> I also want the size to increase in width to some extent and then the Height
> should increase.
> You just create a table in MS-WORD and try this
> It will be better for u to understand what i Want to do.
> I want the same functionality that word provides with the table
>
> plz reply soon
>
> Regards
>
> Pramod
>
>
>
>
> "Andry_R" <[email protected]> wrote in message
> news:[email protected]...
> > Yes, KeyPressed even doesn't occuers when you editing some value in
> DataGrid.
> > But if you want, you can hadle KeyPressed event from parent form (that
> > conatains your DataGrid). To do that just create a handler for KeyPressed
> > event in our form and set form's KeyPreview property to true.
> >
> > -----------------
> > Good luck!
> > Andry
> >
> >
> > "Pramod" wrote:
> >
> > > Hi Vuong,
> > > But there isn't any TextChanged event for the DataGrid.
> > > I have tried to change the width of the column by trapping the KeyPress
> > > event but that doesn't give me the effect as the table of MS-Word has.
> > >
> > > if You find anything related to this plz reply
> > >
> > > Regards ,
> > > Pramod
> > >
> > >
> > >
> > > "Vuong" <[email protected]> wrote in message
> > > news:#[email protected]...
> > > > Pramod,
> > > > You may have to take a look at text changed event.
> > > >
> > > > Vuong
> > > > Tran Xuan
> > > >
> > > > "Pramod" <[email protected]> wrote in message
> > > > news:[email protected]...
> > > > > Hi All,
> > > > >
> > > > > I am working in C# .Net and have created a table using the DataGrid.
> > > > > Now I want to change the size of the column when the user enters
> some
> > > text
> > > > > in the Cell only if the Text entered exceeds the cell bounds.
> > > > >
> > > > > I need help.
> > > > > Urgent!!!!!!!!!!!
> > > > >
> > > > > Plz if any of you could help me.
> > > > >
> > > > > Regards
> > > > > Pramod
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> > >
>
>
>