Click here to Skip to main content
15,906,574 members
Home / Discussions / C#
   

C#

 
GeneralRe: Address from HouseNumber and PostCode Pin
Pete O'Hanlon14-Sep-07 3:34
mvePete O'Hanlon14-Sep-07 3:34 
GeneralRe: Address from HouseNumber and PostCode Pin
Gareth H14-Sep-07 3:54
Gareth H14-Sep-07 3:54 
QuestionAutocorrect functionality in windows forms Pin
chakran14-Sep-07 2:12
chakran14-Sep-07 2:12 
Questionconsole app wrapper help [modified] Pin
mbender14-Sep-07 2:12
mbender14-Sep-07 2:12 
AnswerRe: console app wrapper help Pin
led mike14-Sep-07 5:06
led mike14-Sep-07 5:06 
GeneralRe: console app wrapper help Pin
mbender14-Sep-07 5:11
mbender14-Sep-07 5:11 
Questioncompilation error Pin
deep714-Sep-07 1:54
deep714-Sep-07 1:54 
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 

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.