Showing posts from October, 2011

WPF ComboBox Last item should be selected

If we want that our comboBox will select the last item, in combobox loading time then you can use

  private void LoadComboBo()
            comboBox1.SelectedIndex = comboBox1.Items.Count - 1;


There is no doubt "LINQ" is much more smart that other. In our development we face complex transaction or logical query for our application. Hare is some common LINQ opration. It is important that your all table should be present in dbml file.  Hare PRODUCT_NAME is the table name, In which i will perform All LINQ operation. Product is the class name which will contain data.  table should contain a Primary Key.


public void SaveNewProductName(Product aProduct) { var newProductName = new PRODUCT_NAME { NAME = aProduct.ProductName }; dataContexObj.PRODUCT_NAMEs.InsertOnSubmit(newProductName); dataContexObj.SubmitChanges(); }


public bool DoesExistProductName(Product aProduct) { return (dataContexObj.PRODUCT_NAMEs.Any(o => o.NAME.Contains(aProduct.ProductName))); }


public void UpdateProductName(Product…

How to use code in blogspot

You can easily use your code spinet in your blog. Follow the link:

Hare it is important You have paste your formatted code on your  Blog in  edit HTML view.


WPF DataGrid Cell Color Change

DataGrid's ROW & CELL color Changing is one of most important part in our development. if you want to change Data grid specific cell Background just like:

use the xaml code for "Remaining Day" column in your Datagrid.

<DataGridTemplateColumn Header="Remaining Day" Width="150"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <Border x:Name="brdBroder" VerticalAlignment="Stretch" Margin="1"> <TextBlock Text="{Binding RemainLeave}" Margin="3,1" x:Name="txtTextBlock"/> </Border> <DataTemplate.Triggers> <DataTrigger Binding="{Binding RemainLeave}" Value="0"> <Setter TargetName="brdBroder" Property="Background" Val…

C# LINQ Search between date

The SQL BETWEEN operator we can use in C# code. Before your query you have to use
System.Globalization.CultureInfo culInfo = new System.Globalization.CultureInfo("en-US");  

Consider the Example:
internal List<ECalendarSetup> GetCalenderInfoOnSelectedDate(ECalendarSetup calendarSetup) { ieclHrmDataContext = new IECL_HRMDataContext(); List<ECalendarSetup> calendarSetupsList = new List<ECalendarSetup>(); var query = from j in ieclHrmDataContext.HR_CALENDAR_INFOs where j.CAL_DAY_DATE >= calendarSetup.FromDate && j.CAL_DAY_DATE <= calendarSetup.ToDate select j; foreach (var calendarInfo in query) { ECalendarSetup eCalendarSetup = new ECalendarSetup(); eCalendarSetup.Date = (DateTime) calendarInfo.CAL_DAY_DATE; eCalendarSetup.DayStatus = calendarInfo.CAL_DAY_STATUS; eCalend…

C# string split & LINQ operation

Spliting string in C# is one of the most interesting part. you can also perform your business logic operation on spliting part.
Hare is a list of serial no comes from database, i split the Serial no then just increment id no +1 on maximum serial no, and return to UI.
i also check hare is the serial no is in current year.

internal string GetNewSerialNo() { string refence = ""; DateTime dt = DateTime.Now; List<RFQ> _listAllRef =new List<RFQ>(); foreach (var objrfq in rfqDalObj.GetNewSerialNo()) { string[] splitedRef = (objrfq.SerialNO).Split('-'); if(DateTime.Now.Year.ToString()==splitedRef[1]) { _listAllRef.Add(objrfq); } } List<int> rfqSerials = new List<int>(); if (_listAllRef.Count > 0) { foreach (var obj in _listAllRef) { string[] splitedRef = (obj.SerialNO).Sp…

WPF Common Programming

ListView Binding:

<ListView Height="182" HorizontalAlignment="Left" Name="foodSaleslistView" VerticalAlignment="Top" Width="503" BorderBrush="#00981010" Margin="2,1,0,0"> <ListView.View> <GridView> <GridViewColumn DisplayMemberBinding="{Binding Path=FoodName}" Header="Food name" Width="250" /> <GridViewColumn DisplayMemberBinding="{Binding Path=Qty}" Header="Quantity" Width="100" /> <GridViewColumn DisplayMemberBinding="{Binding Path=TotalPrice}" Header="Total price" Width="150" /> </GridView> </ListView.View> </ListView>
Get Data From ListView:

for (int i = 0; i < headlistView.Items.Count; i++) { EStock anStock = headlistView.Items[i] as EStock; …

Convert TEXT file in to CSV file using Excel

It's really great that you can convert text file in CSV file using Excel. Thn you can save this data in SQL Database. Hare is the link:


WPF 4 Updated Information

There is many new functionality added in WPF 4 Like Visual tree,State Manager,VSM, Touch & manioulation, Graphics & Animation and much more.
 By the following Link You can get idea:


WPF Datagrid highlight border

WPF Datagrid cell {X,Y} coordinate value

Some time we need to find the datagrid selected cell's coordinate value. like

You can easily find our your selected cell value. Please follow this link for more details.