Click here to Skip to main content
15,887,746 members
Home / Discussions / C#
   

C#

 
QuestionHow to: Report generation through Report Viewer control Pin
Spunky Coder14-Sep-07 1:51
Spunky Coder14-Sep-07 1:51 
AnswerRe: How to: Report generation through Report Viewer control Pin
DLM@TD14-Sep-07 12:29
DLM@TD14-Sep-07 12:29 
QuestionDatabinding Issue Pin
RichardContact-114-Sep-07 1:34
RichardContact-114-Sep-07 1:34 
AnswerRe: Databinding Issue Pin
Pete O'Hanlon14-Sep-07 1:45
mvePete O'Hanlon14-Sep-07 1:45 
QuestionWPF UserControl Warning Pin
Michael O.14-Sep-07 1:18
Michael O.14-Sep-07 1:18 
QuestionDockPanel Pin
Mamphekgo Bahula14-Sep-07 1:06
Mamphekgo Bahula14-Sep-07 1:06 
QuestionAutomating the double click required to resize a datagrids columns Pin
c#_keithy14-Sep-07 0:56
c#_keithy14-Sep-07 0:56 
AnswerRe: Automating the double click required to resize a datagrids columns Pin
ElSpinos14-Sep-07 1:14
ElSpinos14-Sep-07 1:14 
Hey Keith,

There is a private method in the DataGrid control class that you can’t access directly through coding, however, all is not lost as Reflection can assist you here. I’ve done this before and implemented however I can’t find the souce I used so here is a brain dump from what I can remember:

<code>
 // You'd probably want to do this every time the data grid changes it's data
 // so implement the DataSourceChanged event...
 private void MyDataGrid_DataSourceChanged(object sender, System.EventArgs e)
 {
  try
  {
   // First lets get the assembly's type reference...
   Type assemblyType = MyDataGrid.GetType();
   // The DataGrid has a method called ColAutoResize (declared as private and no-one knows why)
   // We can invoke this by getting a reference to it in the MethodInfo class.
   MethodInfo methodInfo = assemblyType.GetMethod("ColAutoResize", BindingFlags.NonPublic);

   // Iterate through your columns...
   for (int i = MyDataGrid.FirstVisibleColumn; (i < MyDataGrid.VisibleColumnCount); i++)
   {
    // Invoke the ColAutoResize method, the method expects a single integer
    // column index as the parameter, so we’ll pass I as an argument in the
    // object[] array.
    methodInfo.Invoke(MyDataGrid, new object[] { i });
   }
  }
  catch (Exception ex)
  {
   // Something went horribly wrong, examine the exception and deal 
   // with it accordingly or just simply ignore it, this shouldn’t 
   // happen anyhow...
  }
 }
</code>


I hope this gets you furthur in your project, happy reflectioning! Smile | :)


Fernando Mendes
Senior .NET Developer, Architect

AnswerRe: Automating the double click required to resize a datagrids columns Pin
AETaylor14-Sep-07 1:18
AETaylor14-Sep-07 1:18 
GeneralRe: Automating the double click required to resize a datagrids columns Pin
ElSpinos14-Sep-07 1:42
ElSpinos14-Sep-07 1:42 
QuestionValidation Error when Schema with Entities [modified] Pin
xfun55614-Sep-07 0:24
xfun55614-Sep-07 0:24 
Questionabut dialog Pin
jason_mf13-Sep-07 23:26
jason_mf13-Sep-07 23:26 
AnswerRe: abut dialog Pin
Dave Kreskowiak14-Sep-07 6:29
mveDave Kreskowiak14-Sep-07 6:29 
QuestionHow to find the number of current window handles for a/my process. [modified] Pin
Martin#13-Sep-07 23:06
Martin#13-Sep-07 23:06 
AnswerRe: How to find the number of current window handles for a/my process. Pin
mav.northwind14-Sep-07 4:07
mav.northwind14-Sep-07 4:07 
GeneralRe: How to find the number of current window handles for a/my process. Pin
Martin#14-Sep-07 7:42
Martin#14-Sep-07 7:42 
GeneralRe: How to find the number of current window handles for a/my process. Pin
Martin#18-Sep-07 21:30
Martin#18-Sep-07 21:30 
QuestionRuntime Web Service Invocation Pin
MrEyes13-Sep-07 22:49
MrEyes13-Sep-07 22:49 
AnswerRe: Runtime Web Service Invocation Pin
ElSpinos14-Sep-07 0:15
ElSpinos14-Sep-07 0:15 
GeneralRe: Runtime Web Service Invocation Pin
MrEyes14-Sep-07 1:04
MrEyes14-Sep-07 1:04 
QuestionDatabase and SQL Pin
halalalal13-Sep-07 22:22
halalalal13-Sep-07 22:22 
AnswerRe: Database and SQL Pin
\laddie13-Sep-07 22:25
\laddie13-Sep-07 22:25 
QuestionSmart Phone Devices Pin
halalalal13-Sep-07 21:57
halalalal13-Sep-07 21:57 
AnswerRe: Smart Phone Devices Pin
Dave Kreskowiak14-Sep-07 6:27
mveDave Kreskowiak14-Sep-07 6:27 
Questionhow to display data in list view of mdi children form on search criteria Pin
mukesh choudhary13-Sep-07 21:52
mukesh choudhary13-Sep-07 21:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.