Problem with DatagridView header text middile allignment
Question?
"I've found a lot of answers on how to align the Header Text for a column but when I set the HeaderText to MiddleRight alignment, there is some sort of padding after the Header text that I can't figure out how to get rid of
The code I use to Right Align the column is below:
DataGridView1.Columns(1).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight 'Aligns the Header Text
DataGridView1.Columns(1).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight 'Just aligns the cell contents
I should also mention that I've tried turning EnableHeadersVisualStyles off and that did not solve the problem. I've also tried TopRight and BottomRight with no change."
AnswerThere's a space for the up/down arrow for sorting on that column. If you set the "SortMode" to "NotSortable", you will get what you want:
DataGridView1.Columns(1).S
DataGridView1.Columns(1).H
DataGridView1.Columns(1).D
Read from Excel sheet to Datatable C# code
public static DataTable ReadFromExcel(string fileName)
{
DataTable dt = new DataTable();
try
{
OleDbConnection con = new OleDbConnection(string.Format(@'Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=Excel 8.0', fileName));
OleDbDataAdapter da = new OleDbDataAdapter('select * from list', con);
da.Fill(dt);
}
catch (Exception ex)
{
if (ex.Message.Contains('list'))
{
throw new ExcelRangeException();
}
else
{
throw ex;
}
}
return dt;
}
How to Make an Invisible File Name
How to Make an Invisible File: 6 steps - wikiHow:
"Here's a how-to article on making an invisible folder. This is very useful if you share your computer or you don't want anyone searching for your personal or important files.
- Right Click -> New -> Folder, a new folder should be created.
- Customize the icon. Don't rename it just yet. Right Click the New Folder, go to Properties, then to Customize, and then Change Icon. Here is the trick, go to the middle and you should see some blank spaces. Those are transparent icons, select one of those then press OK -> Apply -> OK.
- Name your folder. Press rename and instead of the file press ALT+0160 (Remember to keep the ALT button pressed down while typing the numbers).
- You should have finished your new invisible file, Congratulations.
- Remember, you must do the numbers in the key pad.
How to start a (SQL) service if it is not running ?
It is simple Batch file that allow to start a windows service ,with checking if it is already running or not
This can re-script as you need.For example it can add to sheduled task for automatic starting and stopping of specified service.For that ,a littile change should be made on file
Replace line 'Set Report=!Report!Running:' with net stop [serviceName]
suggessions are appriciable
:: ================
:: READ THIS FIRST
:: ================
:: * To run this script you must have domain administrators rights.
:: * You need to add service names inside the script
:: * Successful run will generate "ServiceStatusRpt.txt"
:: * Copy and Paste following script into notepad and save it with any name having .cmd or bat extension.
:: Batch Script Start
@ECHO OFF
SETLOCAL EnableDelayedExpansion
WMIC /NODE:"." SERVICE WHERE "Name='MSSQLSERVER' AND State='Running'" GET Status 2>NUL |FIND /I "OK" >NUL
IF NOT ERRORLEVEL 1 (
Set Report=!Report!Running:
) ELSE (
net start MSSQLSERVER
)
ECHO !Report:~0,-1!>>ServiceStatusRpt.txt
Goto EndScript
:EndScript
EXIT /B 0
:: Batch Script End